RESTinio
Loading...
Searching...
No Matches
restinio::router Namespace Reference

Namespaces

namespace  easy_parser_router
namespace  impl
namespace  pcre2_details
namespace  pcre_details

Classes

struct  boost_regex_engine_t
 Regex engine implementation for using with standard regex implementation. More...
class  dynamic_any_of_methods_matcher_t
 An implementation of method_matcher that allows a method if it's found in a dynamic list of allowed methods. More...
class  dynamic_none_of_methods_matcher_t
 An implementation of method_matcher that allows a method if it isn't found in a dynamic list of disabled methods. More...
class  generic_easy_parser_router_t
 A generic request router that uses easy_parser for matching requests with handlers. More...
class  generic_express_route_entry_t
 A single generic express route entry. More...
class  generic_express_router_t
 Generic Express.js style router. More...
struct  method_matcher_t
 An interface of method_matcher. More...
struct  pcre2_regex_engine_t
 Regex engine implementation for PCRE2. More...
struct  pcre2_traits_t
 PCRE traits. More...
struct  pcre_regex_engine_t
 Regex engine implementation for PCRE. More...
struct  pcre_traits_t
 PCRE traits. More...
class  route_params_t
 Parameters extracted from route. More...
struct  std_regex_engine_t
 Regex engine implementation for using with standard regex implementation. More...

Typedefs

using easy_parser_router_t
 A request router that uses easy_parser for matching requests with handlers.
template<typename Extra_Data>
using generic_express_request_handler_t
 Type of generic handler for one route.
using express_request_handler_t
 Type of a handler for one route in the case when there is no extra-data in request object.
template<typename Regex_Engine = std_regex_engine_t>
using express_route_entry_t
 An alias for a single route entry in the case when the default extra-data-factory is used in server's traits.
template<typename Regex_Engine = std_regex_engine_t>
using express_router_t
 A type of express-like router for the case when the default extra-data-factory is specified in the server's traits.
template<typename Extra_Data>
using generic_non_matched_request_handler_t
 A generic type of handler for non-matched requests.
using non_matched_request_handler_t
 A type of handler for non-matched requests for a case when default extra-data-factory is specified in the server's traits.

Functions

template<typename... Args>
impl::fixed_size_any_of_matcher_t< sizeof...(Args) > any_of_methods (Args &&...args)
 A factory function that creates a method_matcher that allows a method if it's found in the list of allowed methods.
template<typename... Args>
impl::fixed_size_none_of_matcher_t< sizeof...(Args) > none_of_methods (Args &&...args)
 A factory function that creates a method_matcher that allows a method if it isn't found in the list of disabled methods.

Typedef Documentation

◆ easy_parser_router_t

Initial value:

A request router that uses easy_parser for matching requests with handlers.

Note
That type is intended to be used when the default extra-data-factory is specified in you server's traits.

Usage example:

auto make_router(...) {
auto router = std::make_unique<router_t>();
...
router->http_get(epr::path_to_params(...),
[](const auto & req, ...) {...});
router->http_post(epr::path_to_params(...),
[](const auto & req, ...) {...});
router->http_delete(epr::path_to_params(...),
[](const auto & req, ...) {...});
router->add_handler(
restinio::http_method_lock(),
epr::path_to_params(...),
[](const auto & req, ...) {...});
router->add_handler(
restinio::http_method_get(),
restinio::http_method_delete(),
restinio::http_method_post()),
epr::path_to_params(...),
[](const auto & req, ...) {...});
router->add_handler(
restinio::http_method_get(),
restinio::http_method_delete(),
restinio::http_method_post()),
epr::path_to_params(...),
[](const auto & req, ...) {...});
return router;
}
...
struct traits_t : public restinio::default_traits_t {
using request_handler_t = router_t;
}
...
restinio::run(
.request_handler(make_router)
...
);
generic_easy_parser_router_t< no_extra_data_factory_t > easy_parser_router_t
A request router that uses easy_parser for matching requests with handlers.
impl::fixed_size_none_of_matcher_t< sizeof...(Args) > none_of_methods(Args &&...args)
A factory function that creates a method_matcher that allows a method if it isn't found in the list o...
impl::fixed_size_any_of_matcher_t< sizeof...(Args) > any_of_methods(Args &&...args)
A factory function that creates a method_matcher that allows a method if it's found in the list of al...
run_on_this_thread_settings_t< Traits > on_this_thread()
A special marker for the case when http_server must be run on the context of the current thread.
traits_t< asio_timer_manager_t, null_logger_t > default_traits_t
Definition traits.hpp:413
Since
v.0.6.6

Definition at line 1170 of file easy_parser_router.hpp.

◆ express_request_handler_t

Initial value:
std::function< request_handling_status_t( generic_request_handle_t< Extra_Data >, route_params_t) > generic_express_request_handler_t
Type of generic handler for one route.
Definition express.hpp:442

Type of a handler for one route in the case when there is no extra-data in request object.

Since v.0.6.13 it's just an alias for generic_express_request_handler_t for the case when the default extra-data-factory is used in server's traits.

Definition at line 459 of file express.hpp.

◆ express_route_entry_t

template<typename Regex_Engine = std_regex_engine_t>
using restinio::router::express_route_entry_t
Initial value:
Regex_Engine,
A single generic express route entry.
Definition express.hpp:476
The default extra-data-factory to be used in server's traits if a user doesn't specify own one.

An alias for a single route entry in the case when the default extra-data-factory is used in server's traits.

Since v.0.6.13 this name is just an alias for generic_express_route_entry_t.

Definition at line 579 of file express.hpp.

◆ express_router_t

template<typename Regex_Engine = std_regex_engine_t>
using restinio::router::express_router_t
Initial value:

A type of express-like router for the case when the default extra-data-factory is specified in the server's traits.

Since v.0.6.13 this type is just an alias for generic_express_router_t with the default extra-data-factory type.

Template Parameters
Regex_EngineType of regex-engine to be used.
Examples
sample/async_chained_handlers/main.cpp, sample/chained_handlers/main.cpp, sample/file_upload/main.cpp, sample/hello_world/main.cpp, and sample/websocket_wss/main.cpp.

Definition at line 844 of file express.hpp.

◆ generic_express_request_handler_t

template<typename Extra_Data>
using restinio::router::generic_express_request_handler_t
Initial value:
std::function<
>
Parameters extracted from route.
Definition express.hpp:57
std::shared_ptr< generic_request_t< Extra_Data > > generic_request_handle_t
An alias for shared-pointer to incoming request.
request_handling_status_t
Request handling status.

Type of generic handler for one route.

Since v.0.6.13 some extra-data can be incorporated into request-object. In that case request-handler will have a different format in comparison with previous versions. The type generic_express_request_handler_t describes a request-handler when extra-data of type Extra_Data is bound to request object.

Note
If the default extra-data-factory in specified in server's traits then the old type express_request_handler_t can be used for the simplicity.
Since
v.0.6.13

Definition at line 442 of file express.hpp.

◆ generic_non_matched_request_handler_t

template<typename Extra_Data>
using restinio::router::generic_non_matched_request_handler_t
Initial value:

A generic type of handler for non-matched requests.

Since v.0.6.13 some extra-data can be incorporated into a request object. In that case request-handler receives a parameter of type generic_request_handle_t<Extra_Data>. The name generic_non_matched_request_handler_t describes a type of generic handler that can be parametrized by a User_Type.

Template Parameters
Extra_DataThe type of extra-data incorporated into a request object.
Since
v.0.6.13

Definition at line 42 of file non_matched_request_handler.hpp.

◆ non_matched_request_handler_t

Initial value:
>
std::function< request_handling_status_t(generic_request_handle_t< Extra_Data >) > generic_non_matched_request_handler_t
A generic type of handler for non-matched requests.
A type of extra-data to be incorporated into a request object by the default.

A type of handler for non-matched requests for a case when default extra-data-factory is specified in the server's traits.

Since v.0.6.13 the name non_matched_request_handler_t is just an alias for generic_non_matched_request_handler_t.

Definition at line 56 of file non_matched_request_handler.hpp.

Function Documentation

◆ any_of_methods()

template<typename... Args>
impl::fixed_size_any_of_matcher_t< sizeof...(Args) > restinio::router::any_of_methods ( Args &&... args)
nodiscard

A factory function that creates a method_matcher that allows a method if it's found in the list of allowed methods.

Usage example:

router->add_handler(
restinio::http_method_get(), restinio::http_method_head()),
"/users/:id",
[](const auto & req, auto & params) {...});
Note
Returns the created object by value without any allocations.
Since
v.0.6.6

Definition at line 417 of file method_matcher.hpp.

◆ none_of_methods()

template<typename... Args>
impl::fixed_size_none_of_matcher_t< sizeof...(Args) > restinio::router::none_of_methods ( Args &&... args)
nodiscard

A factory function that creates a method_matcher that allows a method if it isn't found in the list of disabled methods.

Usage example:

router->add_handler(
restinio::http_method_get(), restinio::http_method_head()),
"/users/:id",
[](const auto & req, auto &) {
return req->create_response(status_method_not_allowed())
.connection_close().done();
});
http_status_line_t status_method_not_allowed()
Note
Returns the created object by value without any allocations.
Since
v.0.6.6
Examples
sample/express_router/main.cpp.

Definition at line 449 of file method_matcher.hpp.