|
| | generic_easy_parser_router_t ()=default |
| |
| | generic_easy_parser_router_t (const generic_easy_parser_router_t &)=delete |
| |
| generic_easy_parser_router_t & | operator= (const generic_easy_parser_router_t &)=delete |
| |
| | generic_easy_parser_router_t (generic_easy_parser_router_t &&)=default |
| |
| generic_easy_parser_router_t & | operator= (generic_easy_parser_router_t &&)=default |
| |
| RESTINIO_NODISCARD request_handling_status_t | operator() (actual_request_handle_t req) const |
| |
| template<typename Method_Matcher , typename Route_Producer , typename Handler > |
| void | add_handler (Method_Matcher &&method_matcher, Route_Producer &&route, Handler &&handler) |
| |
| template<typename Route_Producer , typename Handler > |
| void | http_get (Route_Producer &&route, Handler &&handler) |
| | Set handler for HTTP GET request. More...
|
| |
| template<typename Route_Producer , typename Handler > |
| void | http_delete (Route_Producer &&route, Handler &&handler) |
| | Set handler for HTTP DELETE request. More...
|
| |
| template<typename Route_Producer , typename Handler > |
| void | http_head (Route_Producer &&route, Handler &&handler) |
| | Set handler for HTTP HEAD request. More...
|
| |
| template<typename Route_Producer , typename Handler > |
| void | http_post (Route_Producer &&route, Handler &&handler) |
| | Set handler for HTTP POST request. More...
|
| |
| template<typename Route_Producer , typename Handler > |
| void | http_put (Route_Producer &&route, Handler &&handler) |
| | Set handler for HTTP PUT request. More...
|
| |
| void | non_matched_request_handler (generic_non_matched_request_handler_t< extra_data_t > nmrh) |
| | Set handler for requests that don't match any route. More...
|
| |
template<typename Extra_Data_Factory>
class restinio::router::generic_easy_parser_router_t< Extra_Data_Factory >
A generic request router that uses easy_parser for matching requests with handlers.
- Note
- That type is intended to be used when extra-data-factory for server traits is not the default one. If your server uses the default extra-data-factory then easy_parser_router_t should be used for the simplicity.
Usage example:
struct my_extra_data_factory {
struct data_t {...};
new(buf.
get()) data_t{...};
}
};
my_extra_data_factory >;
auto make_router(...) {
auto router = std::make_unique<router_t>();
...
[](const auto & req, ...) {...});
[](const auto & req, ...) {...});
[](const auto & req, ...) {...});
router->add_handler(
restinio::http_method_lock(),
[](const auto & req, ...) {...});
router->add_handler(
restinio::http_method_get(),
restinio::http_method_delete(),
restinio::http_method_post()),
[](const auto & req, ...) {...});
router->add_handler(
restinio::http_method_get(),
restinio::http_method_delete(),
restinio::http_method_post()),
[](const auto & req, ...) {...});
return router;
}
...
using extra_data_factory_t = my_extra_data_factory;
using request_handler_t = router_t;
}
...
restinio::run(
restinio::on_this_thread<traits_t>()
.request_handler(make_router)
...
);
- Template Parameters
-
| Extra_Data_Factory | The type of user-type-factory. This type should be the same as the traits::user_type_factory_t type for the server. |
- Since
- v.0.6.6, v.0.6.13
Definition at line 949 of file easy_parser_router.hpp.