@@ -10,16 +10,35 @@ namespace httpsserver {
1010
1111/* *
1212 * \brief This HTTPNode represents a route that maps to a regular HTTP request for a resource (static or dynamic)
13- *
13+ *
1414 * It therefore contrasts to the WebsocketNode, which handles requests for Websockets.
1515 */
1616class ResourceNode : public HTTPNode {
1717public:
18- ResourceNode (const std::string &path, const std::string &method, const HTTPSCallbackFunction * callback, const std::string &tag = " " );
18+ /* *
19+ * \brief Create the Resource Node with C++-Style functional attribute.
20+ *
21+ * This variant is more flexible and allows to use std::bind for example to call class member functions.
22+ *
23+ * \param path The path/route to register the handler to, e.g. "/config"
24+ * \param method The method required to match this node, e.g. "GET"
25+ * \param callback The function to call when the route is accessed
26+ * \param tag Optional tag that can be accessed in the handler function. Use it for example to define the roles required to access this route
27+ */
28+ ResourceNode (const std::string &path, const std::string &method, const HTTPSCallbackFunction callback, const std::string &tag = " " );
29+ /* *
30+ * \brief Create the Resource Node with a C-Style function pointer.
31+ *
32+ * \param path The path/route to register the handler to, e.g. "/config"
33+ * \param method The method required to match this node, e.g. "GET"
34+ * \param callback The function callback. Must return void, first parameter is a pointer to a HTTPRequest, second a pointer to a HTTPResponse
35+ * \param tag Optional tag that can be accessed in the handler function. Use it for example to define the roles required to access this route
36+ */
37+ ResourceNode (const std::string &path, const std::string &method, void (*const callback)(HTTPRequest * req, HTTPResponse * res), const std::string &tag = " " );
1938 virtual ~ResourceNode ();
2039
2140 const std::string _method;
22- const HTTPSCallbackFunction * _callback;
41+ const HTTPSCallbackFunction _callback;
2342 std::string getMethod () { return _method; }
2443};
2544
0 commit comments