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 >
168template<
typename Unescape_Traits >
178 return restinio::utils::unescape_percent_encoding< Unescape_Traits >(
192template<
typename Producer, std::
size_t Index >
194 :
public ep::impl::consume_value_clause_t<
196 ep::impl::tuple_item_consumer_t<Index> >
205 template<
typename Producer_Arg >
210 return { std::forward<Producer_Arg>(producer) };
214 template<
typename Producer_Arg >
235template< std::
size_t Size >
237 :
public ep::impl::consume_value_clause_t<
238 ep::impl::exact_fixed_size_fragment_producer_t<Size>,
239 ep::impl::any_value_skipper_t >
241 using producer_t = ep::impl::exact_fixed_size_fragment_producer_t<Size>;
250 const char (&fragment)[
Size] )
269 :
public ep::impl::consume_value_clause_t<
270 ep::impl::exact_fragment_producer_t,
271 ep::impl::any_value_skipper_t >
296template<
typename H,
typename R,
bool Is_Producer >
301 template<
class...>
class To,
310 template<
class...>
class To,
318template<
typename H,
typename R >
324template<
typename From,
typename To >
329 template<
class...>
class From,
331 template<
class...>
class To,
344 template<
class...>
class From,
345 template<
class...>
class To,
353template<
typename Args_Type_List >
363template<
typename Args_Type_List >
375template<
typename T,
bool Is_Producer, std::
size_t Current_Index >
382template< std::
size_t Size, std::
size_t Current_Index >
389template< std::
size_t Current_Index >
396template< std::
size_t Current_Index >
403template<
typename T, std::
size_t Current_Index >
414template<
typename From,
typename To, std::
size_t Current_Index >
418 template<
class...>
class From,
420 template<
class...>
class To,
430 ep::impl::is_producer_v<head_type>,
437 one_clause_type::next_index >::type;
441 template<
class...>
class From,
442 template<
class...>
class To,
452template<
typename Args_Type_List >
463template<
typename Args_Type_List >
483template<
typename T >
487 using U = std::remove_reference_t<T>;
490 using type =
typename std::conditional<
491 std::is_array<U>::value,
515template<
typename...
Args >
518 static_assert( 0
u !=
sizeof...(Args),
"Args can't be an empty list" );
543 :
public ep::impl::produce_t< Target_Type, Subitems_Tuple >
545 using base_type_t = ep::impl::produce_t< Target_Type, Subitems_Tuple >;
548 using base_type_t::base_type_t;
550 template<
typename Extra_Data,
typename Handler >
556 typename base_type_t::result_type & type )
562namespace path_to_params_details
575 std::index_sequence<Indexes...> )
577 return std::forward<F>(
what)(
579 std::get<Indexes>(std::forward<Tuple>(params))... );
592template<
typename F,
typename Extra_Data,
typename Tuple >
600 std::forward<F>(
what),
602 std::forward<Tuple>(params),
603 std::make_index_sequence<
604 std::tuple_size< std::remove_reference_t<Tuple> >::value
626 :
public ep::impl::produce_t< Target_Type, Subitems_Tuple >
628 using base_type_t = ep::impl::produce_t< Target_Type, Subitems_Tuple >;
631 using base_type_t::base_type_t;
633 template<
typename User_Type,
typename Handler >
639 typename base_type_t::result_type & type )
691template<
typename...
Args >
745template<
typename...
Args >
948template<
typename Extra_Data_Factory >
971 using namespace easy_parser_router::impl;
1009 using namespace easy_parser_router::impl;
1017 auto entry = std::make_unique< actual_entry_type >(
1019 std::forward<Route_Producer>(
route),
1020 std::forward<Handler>(
handler) );
1026 template<
typename Route_Producer,
typename Handler >
1034 std::forward<Route_Producer>(
route),
1035 std::forward<Handler>(
handler) );
1039 template<
typename Route_Producer,
typename Handler >
1047 std::forward<Route_Producer>(
route),
1048 std::forward<Handler>(
handler) );
1052 template<
typename Route_Producer,
typename Handler >
1060 std::forward<Route_Producer>(
route),
1061 std::forward<Handler>(
handler) );
1065 template<
typename Route_Producer,
typename Handler >
1073 std::forward<Route_Producer>(
route),
1074 std::forward<Handler>(
handler) );
1078 template<
typename Route_Producer,
typename Handler >
1086 std::forward<Route_Producer>(
route),
1087 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.
typename router_entry_t< Extra_Data >::actual_request_handle_t actual_request_handle_t
actual_router_entry_t(Method_Matcher &&method_matcher, Producer_Arg &&producer, Handler_Arg &&handler)
Handler m_handler
Request handler to be used.
RESTINIO_NODISCARD 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.
restinio::router::impl::buffered_matcher_holder_t m_method_matcher
HTTP method to match.
An implementation of a producer for path_to_params case.
static RESTINIO_NODISCARD auto invoke_handler(const generic_request_handle_t< User_Type > &req, Handler &&handler, typename base_type_t::result_type &type)
ep::impl::produce_t< Target_Type, Subitems_Tuple > base_type_t
An implementation of a producer for path_to_tuple case.
ep::impl::produce_t< Target_Type, Subitems_Tuple > base_type_t
static RESTINIO_NODISCARD 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 RESTINIO_NODISCARD 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.
virtual ~router_entry_t()=default
generic_request_handle_t< Extra_Data > actual_request_handle_t
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::any_value_skipper_t consumer_t
ep::impl::consume_value_clause_t< producer_t, consumer_t > base_type_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.
ep::impl::tuple_item_consumer_t< Index > consumer_t
static RESTINIO_NODISCARD Producer make_producer(Producer_Arg &&producer)
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
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.
generic_easy_parser_router_t(generic_easy_parser_router_t &&)=default
generic_easy_parser_router_t()=default
std::vector< easy_parser_router::impl::router_entry_unique_ptr_t< extra_data_t > > entries_container_t
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.
RESTINIO_NODISCARD request_handling_status_t operator()(actual_request_handle_t req) const
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.
#define RESTINIO_NODISCARD
An very small, simple and somewhat limited implementation of recursive-descent parser.
Stuff related to method_matchers.
RESTINIO_NODISCARD auto any_symbol_if_not_p(char sentinel) noexcept
A factory function to create a any_symbol_if_not_producer.
RESTINIO_NODISCARD 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.
RESTINIO_NODISCARD auto repeat(std::size_t min_occurences, std::size_t max_occurences, Clauses &&... clauses)
A factory function to create repetitor of subclauses.
constexpr std::size_t N
A special marker that means infinite repetitions.
RESTINIO_NODISCARD auto to_container()
A factory function to create a to_container_consumer.
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.
RESTINIO_NODISCARD 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...
RESTINIO_NODISCARD auto path_fragment_p(char separator='/')
A factory that creates a string-producer that extracts a sequence on symbols until the separator will...
RESTINIO_NODISCARD auto unescape()
A factory for unescape_transformer.
RESTINIO_NODISCARD auto path_to_tuple(Args &&...args)
Describe a route for a handler that accepts params from the route in form of a tuple.
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.
RESTINIO_NODISCARD constexpr request_handling_status_t request_not_handled() noexcept
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.
nonstd::string_view string_view_t
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.
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.
std::remove_reference_t< T > U
typename std::conditional< std::is_array< U >::value, U, std::remove_cv_t< U > >::type type
The main meta-function for processing route DSL.
dsl_details::make_clauses_types_t< arg_types > clauses_tuple
dsl_details::detect_result_tuple_t< arg_types > result_tuple
meta::transform_t< dsl_details::special_decay, meta::type_list< Args... > > arg_types
Helper type to indicate a negative match attempt.
virtual RESTINIO_NODISCARD 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.