@@ -10,16 +10,35 @@ namespace httpsserver {
10
10
11
11
/* *
12
12
* \brief This HTTPNode represents a route that maps to a regular HTTP request for a resource (static or dynamic)
13
- *
13
+ *
14
14
* It therefore contrasts to the WebsocketNode, which handles requests for Websockets.
15
15
*/
16
16
class ResourceNode : public HTTPNode {
17
17
public:
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 = " " );
19
38
virtual ~ResourceNode ();
20
39
21
40
const std::string _method;
22
- const HTTPSCallbackFunction * _callback;
41
+ const HTTPSCallbackFunction _callback;
23
42
std::string getMethod () { return _method; }
24
43
};
25
44
0 commit comments