28namespace easy_parser_router
54template<
typename Extra_Data >
85template<
typename Extra_Data >
87 std::unique_ptr< router_entry_t< Extra_Data > >;
105template<
typename Extra_Data,
typename Producer,
typename Handler >
165template<
typename Unescape_Traits >
175 return restinio::utils::unescape_percent_encoding< Unescape_Traits >(
189template<
typename Producer, std::
size_t Index >
191 :
public ep::impl::consume_value_clause_t<
193 ep::impl::tuple_item_consumer_t<Index> >
202 template<
typename Producer_Arg >
207 return { std::forward<Producer_Arg>(producer) };
211 template<
typename Producer_Arg >
232template< std::
size_t Size >
234 :
public ep::impl::consume_value_clause_t<
235 ep::impl::exact_fixed_size_fragment_producer_t<Size>,
236 ep::impl::any_value_skipper_t >
238 using producer_t = ep::impl::exact_fixed_size_fragment_producer_t<Size>;
247 const char (&fragment)[
Size] )
266 :
public ep::impl::consume_value_clause_t<
267 ep::impl::exact_fragment_producer_t,
268 ep::impl::any_value_skipper_t >
293template<
typename H,
typename R,
bool Is_Producer >
298 template<
class...>
class To,
307 template<
class...>
class To,
315template<
typename H,
typename R >
321template<
typename From,
typename To >
326 template<
class...>
class From,
328 template<
class...>
class To,
341 template<
class...>
class From,
342 template<
class...>
class To,
350template<
typename Args_Type_List >
360template<
typename Args_Type_List >
372template<
typename T,
bool Is_Producer, std::
size_t Current_Index >
379template< std::
size_t Size, std::
size_t Current_Index >
386template< std::
size_t Current_Index >
393template< std::
size_t Current_Index >
400template<
typename T, std::
size_t Current_Index >
411template<
typename From,
typename To, std::
size_t Current_Index >
415 template<
class...>
class From,
417 template<
class...>
class To,
427 ep::impl::is_producer_v<head_type>,
434 one_clause_type::next_index >::type;
438 template<
class...>
class From,
439 template<
class...>
class To,
449template<
typename Args_Type_List >
460template<
typename Args_Type_List >
480template<
typename T >
484 using U = std::remove_reference_t<T>;
487 using type =
typename std::conditional<
488 std::is_array<U>::value,
512template<
typename...
Args >
515 static_assert( 0
u !=
sizeof...(Args),
"Args can't be an empty list" );
540 :
public ep::impl::produce_t< Target_Type, Subitems_Tuple >
542 using base_type_t = ep::impl::produce_t< Target_Type, Subitems_Tuple >;
545 using base_type_t::base_type_t;
547 template<
typename Extra_Data,
typename Handler >
553 typename base_type_t::result_type & type )
559namespace path_to_params_details
572 std::index_sequence<Indexes...> )
574 return std::forward<F>(
what)(
576 std::get<Indexes>(std::forward<Tuple>(params))... );
589template<
typename F,
typename Extra_Data,
typename Tuple >
597 std::forward<F>(
what),
599 std::forward<Tuple>(params),
600 std::make_index_sequence<
601 std::tuple_size< std::remove_reference_t<Tuple> >::value
623 :
public ep::impl::produce_t< Target_Type, Subitems_Tuple >
625 using base_type_t = ep::impl::produce_t< Target_Type, Subitems_Tuple >;
628 using base_type_t::base_type_t;
630 template<
typename User_Type,
typename Handler >
636 typename base_type_t::result_type & type )
688template<
typename...
Args >
742template<
typename...
Args >
945template<
typename Extra_Data_Factory >
968 using namespace easy_parser_router::impl;
1006 using namespace easy_parser_router::impl;
1014 auto entry = std::make_unique< actual_entry_type >(
1016 std::forward<Route_Producer>(
route),
1017 std::forward<Handler>(
handler) );
1023 template<
typename Route_Producer,
typename Handler >
1031 std::forward<Route_Producer>(
route),
1032 std::forward<Handler>(
handler) );
1036 template<
typename Route_Producer,
typename Handler >
1044 std::forward<Route_Producer>(
route),
1045 std::forward<Handler>(
handler) );
1049 template<
typename Route_Producer,
typename Handler >
1057 std::forward<Route_Producer>(
route),
1058 std::forward<Handler>(
handler) );
1062 template<
typename Route_Producer,
typename Handler >
1070 std::forward<Route_Producer>(
route),
1071 std::forward<Handler>(
handler) );
1075 template<
typename Route_Producer,
typename Handler >
1083 std::forward<Route_Producer>(
route),
1084 std::forward<Handler>(
handler) );
An actual implementation of router_entry interface.
Producer m_producer
Parser of a route and producer of argument(s) for request handler.
expected_t< request_handling_status_t, no_match_t > try_handle(const actual_request_handle_t &req, target_path_holder_t &target_path) const override
An attempt to match a request against the route.
actual_router_entry_t(Method_Matcher &&method_matcher, Producer_Arg &&producer, Handler_Arg &&handler)
typename router_entry_t< Extra_Data >::actual_request_handle_t actual_request_handle_t
Handler m_handler
Request handler to be used.
restinio::router::impl::buffered_matcher_holder_t m_method_matcher
HTTP method to match.
An implementation of a producer for path_to_params case.
ep::impl::produce_t< Target_Type, Subitems_Tuple > base_type_t
static auto invoke_handler(const generic_request_handle_t< User_Type > &req, Handler &&handler, typename base_type_t::result_type &type)
An implementation of a producer for path_to_tuple case.
ep::impl::produce_t< Target_Type, Subitems_Tuple > base_type_t
static auto invoke_handler(const generic_request_handle_t< Extra_Data > &req, Handler &&handler, typename base_type_t::result_type &type)
An interface for one entry of easy_parser-based router.
virtual ~router_entry_t()=default
generic_request_handle_t< Extra_Data > actual_request_handle_t
virtual expected_t< request_handling_status_t, no_match_t > try_handle(const actual_request_handle_t &req, target_path_holder_t &target_path) const =0
An attempt to match a request against the route.
A special clause type for case when exact_fixed_size_fragment_producer should be used without storing...
ep::impl::exact_fixed_size_fragment_producer_t< Size > producer_t
ep::impl::consume_value_clause_t< producer_t, consumer_t > base_type_t
ep::impl::any_value_skipper_t consumer_t
special_exact_fixed_size_fragment_clause_t(const char(&fragment)[Size])
A special clause type for case when exact_fragment_producer should be used without storing its value.
special_exact_fragment_clause_t(string_view_t value)
ep::impl::consume_value_clause_t< producer_t, consumer_t > base_type_t
ep::impl::any_value_skipper_t consumer_t
special_exact_fragment_clause_t(std::string value)
ep::impl::exact_fragment_producer_t producer_t
A special case of produce-consume clause where the produced value is stored into a tuple.
static Producer make_producer(Producer_Arg &&producer)
ep::impl::tuple_item_consumer_t< Index > consumer_t
ep::impl::consume_value_clause_t< Producer, consumer_t > base_type_t
special_produce_tuple_item_clause_t(Producer_Arg &&producer)
A generic request router that uses easy_parser for matching requests with handlers.
void add_handler(Method_Matcher &&method_matcher, Route_Producer &&route, Handler &&handler)
typename Extra_Data_Factory::data_t extra_data_t
std::vector< easy_parser_router::impl::router_entry_unique_ptr_t< extra_data_t > > entries_container_t
generic_request_handle_t< extra_data_t > actual_request_handle_t
generic_easy_parser_router_t & operator=(generic_easy_parser_router_t &&)=default
void http_get(Route_Producer &&route, Handler &&handler)
Set handler for HTTP GET request.
void http_head(Route_Producer &&route, Handler &&handler)
Set handler for HTTP HEAD request.
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.
generic_easy_parser_router_t & operator=(const generic_easy_parser_router_t &)=delete
generic_non_matched_request_handler_t< extra_data_t > m_non_matched_request_handler
Handler that is called for requests that don't match any route.
void http_delete(Route_Producer &&route, Handler &&handler)
Set handler for HTTP DELETE request.
request_handling_status_t operator()(actual_request_handle_t req) const
generic_easy_parser_router_t(generic_easy_parser_router_t &&)=default
generic_easy_parser_router_t()=default
void http_post(Route_Producer &&route, Handler &&handler)
Set handler for HTTP POST request.
entries_container_t m_entries
generic_easy_parser_router_t(const generic_easy_parser_router_t &)=delete
void http_put(Route_Producer &&route, Handler &&handler)
Set handler for HTTP PUT request.
A special class that allows to hold a copy of small-size method_matchers or a pointer to dynamically ...
Helper class for holding a unique instance of char array with target_path value.
An very small, simple and somewhat limited implementation of recursive-descent parser.
Stuff related to method_matchers.
auto to_container()
A factory function to create a to_container_consumer.
expected_t< typename Producer::result_type, parse_error_t > try_parse(string_view_t from, Producer producer)
Perform the parsing of the specified content by using specified value producer.
auto any_symbol_if_not_p(char sentinel) noexcept
A factory function to create a any_symbol_if_not_producer.
constexpr std::size_t N
A special marker that means infinite repetitions.
auto repeat(std::size_t min_occurences, std::size_t max_occurences, Clauses &&... clauses)
A factory function to create repetitor of subclauses.
typename detect_result_tuple< Args_Type_List >::type detect_result_tuple_t
typename make_clauses_types< Args_Type_List >::type make_clauses_types_t
decltype(auto) call_with_tuple_impl(F &&what, const generic_request_handle_t< Extra_Data > &req, Tuple &¶ms, std::index_sequence< Indexes... >)
decltype(auto) call_with_tuple(F &&what, const generic_request_handle_t< Extra_Data > &req, Tuple &¶ms)
A helper function to call a request-handler with a tuple.
std::unique_ptr< router_entry_t< Extra_Data > > router_entry_unique_ptr_t
An alias for unique_ptr of router_entry.
auto path_to_tuple(Args &&...args)
Describe a route for a handler that accepts params from the route in form of a tuple.
auto path_to_params(Args &&...args)
Describe a route for a handler that accepts params from the route in form of a list of separate argum...
auto path_fragment_p(char separator='/')
A factory that creates a string-producer that extracts a sequence on symbols until the separator will...
auto unescape()
A factory for unescape_transformer.
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.
std::shared_ptr< generic_request_t< Extra_Data > > generic_request_handle_t
An alias for shared-pointer to incoming request.
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.
std::string_view string_view_t
constexpr request_handling_status_t request_not_handled() noexcept
request_handling_status_t
Request handling status.
nonstd::expected< T, E > expected_t
The definition of the non_matched_request_handler type.
To< Results..., typename H::result_type > type
meta::head_of_t< Sources... > head_type
typename clauses_type_maker< meta::tail_of_t< Sources... >, To< Results..., typename one_clause_type::clause_type >, one_clause_type::next_index >::type type
meta::rename_t< typename result_tuple_detector< Args_Type_List, meta::type_list<> >::type, std::tuple > type
meta::rename_t< typename clauses_type_maker< Args_Type_List, meta::type_list<>, 0u >::type, std::tuple > type
static constexpr std::size_t next_index
typename result_tuple_detector< meta::tail_of_t< Sources... >, typename add_type_if_necessary< meta::head_of_t< Sources... >, To< Results... > >::type >::type type
A special analog of std::decay meta-function that is handles array differently.
typename std::conditional< std::is_array< U >::value, U, std::remove_cv_t< U > >::type type
std::remove_reference_t< T > U
The main meta-function for processing route DSL.
meta::transform_t< dsl_details::special_decay, meta::type_list< Args... > > arg_types
dsl_details::make_clauses_types_t< arg_types > clauses_tuple
dsl_details::detect_result_tuple_t< arg_types > result_tuple
Helper type to indicate a negative match attempt.
virtual bool match(const http_method_id_t &method) const noexcept=0
Is the specified method can be applied to a route?
The default traits for escaping and unexcaping symbols in a query string.
Implementation of target_path_holder helper class.