add overload for PIHTTPServer::register* for pointer to a member function

This commit is contained in:
2025-04-30 15:07:25 +03:00
parent 8a61cfe7ef
commit dfdc4b8bdc

View File

@@ -13,7 +13,16 @@ public:
using RequestFunction = std::function<PIHTTP::MessageMutable(const PIHTTP::MessageConst &)>;
void registerPath(const PIString & path, PIHTTP::Method method, RequestFunction functor);
template<typename T>
void
registerPath(const PIString & path, PIHTTP::Method method, T * o, PIHTTP::MessageMutable (T::*function)(const PIHTTP::MessageConst &)) {
registerPath(path, method, [o, function](const PIHTTP::MessageConst & m) { return (o->*function)(m); });
}
void registerUnhandled(RequestFunction functor);
template<typename T>
void registerUnhandled(T * o, PIHTTP::MessageMutable (T::*function)(const PIHTTP::MessageConst &)) {
registerUnhandled([o, function](const PIHTTP::MessageConst & m) { return (o->*function)(m); });
}
void unregisterPath(const PIString & path, PIHTTP::Method method);
void unregisterPath(const PIString & path);