Libevent library (https://libevent.org/) provides functionality to create your own HTTP server. As I know, there are two ways to set request handlers (appropriate callbacks and general callback):
// Set callback for appropriate request
evhttp_set_cb (server, "/test", handler_1, 0);
// Set callback for appropriate request
evhttp_set_cb (server, "/test/about", handler_2, 0);
// Set general callback for all other requests
evhttp_set_gencb (server, general_handler, 0);
http://www.wangafu.net/~nickm/libevent-2.0/doxygen/html/http_8h.html
I wonder if it is possible somehow to use evhttp_set_cb
function to set one callback that will be called on appropriate pattern, like:
/*
Call `handler_1` callback with next requests:
/test
/test?param=value
/test/id1
/test/id2
...
*/
evhttp_set_cb (server, "/test*", handler_test, 0);
I know that general callback can be used for such purposes (evhttp_set_gencb
) but it will handle absolutely all requests (not only that start from /test
).
Thanks in advance.