From dfdc4b8bdc7ccc34d3efd85b2e0f7ef65425c52a Mon Sep 17 00:00:00 2001 From: peri4 Date: Wed, 30 Apr 2025 15:07:25 +0300 Subject: [PATCH] add overload for PIHTTPServer::register* for pointer to a member function --- libs/main/http_server/pihttpserver.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/main/http_server/pihttpserver.h b/libs/main/http_server/pihttpserver.h index 3c755023..0c3f82b4 100644 --- a/libs/main/http_server/pihttpserver.h +++ b/libs/main/http_server/pihttpserver.h @@ -13,7 +13,16 @@ public: using RequestFunction = std::function; void registerPath(const PIString & path, PIHTTP::Method method, RequestFunction functor); + template + 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 + 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);