|
| generic_express_router_t ()=default |
|
| generic_express_router_t (generic_express_router_t &&)=default |
|
RESTINIO_NODISCARD request_handling_status_t | operator() (actual_request_handle_t req) const |
|
void | non_matched_request_handler (non_matched_handler_t nmrh) |
| Set handler for requests that don't match any route. More...
|
|
|
template<typename Method_Matcher > |
void | add_handler (Method_Matcher &&method_matcher, string_view_t route_path, actual_request_handler_t handler) |
| Add handlers. More...
|
|
template<typename Method_Matcher > |
void | add_handler (Method_Matcher &&method_matcher, string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler) |
|
void | http_delete (string_view_t route_path, actual_request_handler_t handler) |
|
void | http_delete (string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler) |
|
void | http_get (string_view_t route_path, actual_request_handler_t handler) |
|
void | http_get (string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler) |
|
void | http_head (string_view_t route_path, actual_request_handler_t handler) |
|
void | http_head (string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler) |
|
void | http_post (string_view_t route_path, actual_request_handler_t handler) |
|
void | http_post (string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler) |
|
void | http_put (string_view_t route_path, actual_request_handler_t handler) |
|
void | http_put (string_view_t route_path, const path2regex::options_t &options, actual_request_handler_t handler) |
|
template<typename Regex_Engine, typename Extra_Data_Factory>
class restinio::router::generic_express_router_t< Regex_Engine, Extra_Data_Factory >
Generic Express.js style router.
Express routers acts as a request handler (it means it is a function-object that can be called as a restinio request handler). It aggregates several endpoint-handlers and picks one or none of them to handle the request. The choice of the handler to execute depends on request target and HTTP method.
If router finds no handler matching the request then request is considered unmatched.
It is possible to set a handler for unmatched requests, otherwise router rejects the request and RESTinio takes care of it.
There is a difference between ordinary restinio request handler and the one that is used with experss router: generic_express_request_handler_t. The signature of a handlers that can be put in router has an additional parameter – a container with parameters extracted from URI (request target).
- Template Parameters
-
Regex_Engine | Type of regex-engine to be used. |
Extra_Data_Factory | Type of extra-data-factory specified in server's traits. |
- Examples
- sample/chained_handlers/main.cpp, sample/extra_data_factory/main.cpp, sample/file_upload/main.cpp, sample/hello_world/main.cpp, and sample/websocket_wss/main.cpp.
Definition at line 611 of file express.hpp.