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 = generic_easy_parser_router_t< no_extra_data_factory_t >
| A request router that uses easy_parser for matching requests with handlers.
template<typename Extra_Data >
using | generic_express_request_handler_t = std::function< request_handling_status_t(generic_request_handle_t< Extra_Data >, route_params_t) >
| Type of generic handler for one route.
using | express_request_handler_t = generic_express_request_handler_t< no_extra_data_factory_t::data_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 = generic_express_route_entry_t< Regex_Engine, no_extra_data_factory_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 = generic_express_router_t< Regex_Engine, no_extra_data_factory_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 = std::function< request_handling_status_t(generic_request_handle_t< Extra_Data >) >
| A generic type of handler for non-matched requests.
using | non_matched_request_handler_t = generic_non_matched_request_handler_t< no_extra_data_factory_t::data_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>
RESTINIO_NODISCARD 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>
RESTINIO_NODISCARD 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

using restinio::router::easy_parser_router_t = typedef generic_easy_parser_router_t< no_extra_data_factory_t >

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:

using router_t = restinio::router::easy_parser_router_t;
namespace epr = restinio::router::easy_parser_router;
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::router::any_of_methods(
restinio::http_method_get(),
restinio::http_method_delete(),
restinio::http_method_post()),
epr::path_to_params(...),
[](const auto & req, ...) {...});
router->add_handler(
restinio::router::none_of_methods(
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(
restinio::on_this_thread<traits_t>()
.request_handler(make_router)
...
);
restinio::router::easy_parser_router
Definition: easy_parser_router.hpp:29
restinio::router::easy_parser_router_t
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.
Definition: easy_parser_router.hpp:1171
restinio::router::any_of_methods
RESTINIO_NODISCARD 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...
Definition: method_matcher.hpp:417
restinio::router::none_of_methods
RESTINIO_NODISCARD 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...
Definition: method_matcher.hpp:449
restinio::traits_t
Definition: traits.hpp:147

Since
  v.0.6.6

Definition at line 1170 of file easy_parser_router.hpp.

## express_request_handler_t

using restinio::router::express_request_handler_t = typedef generic_express_request_handler_t< no_extra_data_factory_t::data_t >

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 460 of file express.hpp.

## express_route_entry_t

template<typename Regex_Engine = std_regex_engine_t>

using restinio::router::express_route_entry_t = typedef generic_express_route_entry_t< Regex_Engine, no_extra_data_factory_t >

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 580 of file express.hpp.

## express_router_t

template<typename Regex_Engine = std_regex_engine_t>

using restinio::router::express_router_t = typedef generic_express_router_t< Regex_Engine, no_extra_data_factory_t >

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_Engine | Type of regex-engine to be used.

Definition at line 845 of file express.hpp.

## generic_express_request_handler_t

template<typename Extra_Data >

using restinio::router::generic_express_request_handler_t = typedef std::function< request_handling_status_t( generic_request_handle_t<Extra_Data>, route_params_t ) >

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 443 of file express.hpp.

## generic_non_matched_request_handler_t

template<typename Extra_Data >

using restinio::router::generic_non_matched_request_handler_t = typedef std::function< request_handling_status_t( generic_request_handle_t<Extra_Data> ) >

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_Data | The 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

using restinio::router::non_matched_request_handler_t = typedef generic_non_matched_request_handler_t< no_extra_data_factory_t::data_t >

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>

RESTINIO_NODISCARD impl::fixed_size_any_of_matcher_t< sizeof...(Args) > restinio::router::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.

Usage example:

router->add_handler(
restinio::router::any_of_methods(
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>

RESTINIO_NODISCARD impl::fixed_size_none_of_matcher_t< sizeof...(Args) > restinio::router::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.

Usage example:

router->add_handler(
restinio::router::none_of_methods(
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();
});
restinio::response_connection_attr_t::connection_close
@ connection_close
This response says to close connection.
restinio::status_method_not_allowed
http_status_line_t status_method_not_allowed()
Definition: http_headers.hpp:2233

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.