14 #include <restinio/router/impl/target_path_holder.hpp> 15 #include <restinio/router/non_matched_request_handler.hpp> 16 #include <restinio/router/method_matcher.hpp> 18 #include <restinio/helpers/easy_parser.hpp> 54 template<
typename Extra_Data >
105 template<
typename Extra_Data,
typename Producer,
typename Handler >
121 using actual_request_handle_t =
125 typename Method_Matcher,
126 typename Producer_Arg,
127 typename Handler_Arg >
129 Method_Matcher && method_matcher,
130 Producer_Arg && producer,
131 Handler_Arg && handler )
168 template<
typename Unescape_Traits >
192 template<
typename Producer, std::size_t Index >
235 template< std::size_t Size >
250 const char (&fragment)[Size] )
296 template<
typename H,
typename R,
bool Is_Producer >
297 struct add_type_if_necessary_impl;
301 template<
class...>
class To,
302 typename... Results >
303 struct add_type_if_necessary_impl< H, To<Results...>,
false >
305 using type = To<Results...>;
310 template<
class...>
class To,
311 typename... Results >
312 struct add_type_if_necessary_impl< H, To<Results...>,
true >
314 using type = To<Results...,
typename H::result_type>;
318 template<
typename H,
typename R >
324 template<
typename From,
typename To >
325 struct result_tuple_detector;
329 template<
class...>
class From,
331 template<
class...>
class To,
332 typename... Results >
333 struct result_tuple_detector< From<Sources...>, To<Results...> >
335 using type =
typename result_tuple_detector<
336 meta::tail_of_t< Sources... >,
337 typename add_type_if_necessary<
338 meta::head_of_t< Sources... >,
339 To< Results... > >::type
344 template<
class...>
class From,
345 template<
class...>
class To,
346 typename... Results >
347 struct result_tuple_detector< From<>, To<Results...> >
349 using type = To<Results...>;
353 template<
typename Args_Type_List >
363 template<
typename Args_Type_List >
375 template<
typename T,
bool Is_Producer, std::size_t Current_Index >
378 using clause_type = T;
382 template< std::size_t Size, std::size_t Current_Index >
403 template<
typename T, std::size_t Current_Index >
414 template<
typename From,
typename To, std::size_t Current_Index >
415 struct clauses_type_maker;
418 template<
class...>
class From,
420 template<
class...>
class To,
422 std::size_t Current_Index >
423 struct clauses_type_maker< From<Sources...>, To<Results...>, Current_Index >
426 using head_type = meta::head_of_t< Sources... >;
428 using one_clause_type = one_clause_type_processor<
430 ep::impl::is_producer_v<head_type>,
434 using type =
typename clauses_type_maker<
435 meta::tail_of_t< Sources... >,
436 To< Results...,
typename one_clause_type::clause_type >,
437 one_clause_type::next_index >::type;
441 template<
class...>
class From,
442 template<
class...>
class To,
444 std::size_t Current_Index >
445 struct clauses_type_maker< From<>, To<Results...>, Current_Index >
447 using type = To< Results... >;
452 template<
typename Args_Type_List >
463 template<
typename Args_Type_List >
483 template<
typename T >
515 template<
typename... Args >
518 static_assert( 0u !=
sizeof...(Args),
"Args can't be an empty list" );
540 typename Target_Type,
541 typename Subitems_Tuple >
569 std::size_t... Indexes >
573 const generic_request_handle_t< Extra_Data > & req,
577 return std::forward<F>(what)(
579 std::get<Indexes>(std::forward<Tuple>(params))... );
592 template<
typename F,
typename Extra_Data,
typename Tuple >
596 const generic_request_handle_t< Extra_Data > & req,
599 return call_with_tuple_impl(
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
623 typename Target_Type,
624 typename Subitems_Tuple >
691 template<
typename...
Args >
745 template<
typename...
Args >
948 template<
typename Extra_Data_Factory >
951 using extra_data_t =
typename Extra_Data_Factory::data_t;
968 request_handling_status_t
special_exact_fragment_clause_t(string_view_t value)
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.
static constexpr std::size_t next_index
generic_easy_parser_router_t & operator=(const generic_easy_parser_router_t &)=delete
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.
entries_container_t m_entries
static RESTINIO_NODISCARD auto invoke_handler(const generic_request_handle_t< Extra_Data > &req, Handler &&handler, typename base_type_t::result_type &type)
static RESTINIO_NODISCARD auto invoke_handler(const generic_request_handle_t< User_Type > &req, Handler &&handler, typename base_type_t::result_type &type)
Helper type to indicate a negative match attempt.
A special analog of std::decay meta-function that is handles array differently.
generic_easy_parser_router_t(generic_easy_parser_router_t &&)=default
A special clause type for case when exact_fragment_producer should be used without storing its value...
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.
Producer m_producer
Parser of a route and producer of argument(s) for request handler.
actual_router_entry_t(Method_Matcher &&method_matcher, Producer_Arg &&producer, Handler_Arg &&handler)
Handler m_handler
Request handler to be used.
restinio::router::impl::buffered_matcher_holder_t m_method_matcher
HTTP method to match.
special_produce_tuple_item_clause_t(Producer_Arg &&producer)
The main meta-function for processing route DSL.
A special clause type for case when exact_fixed_size_fragment_producer should be used without storing...
RESTINIO_NODISCARD auto unescape()
A factory for unescape_transformer.
generic_easy_parser_router_t(const generic_easy_parser_router_t &)=delete
decltype(auto) call_with_tuple_impl(F &&what, const generic_request_handle_t< Extra_Data > &req, Tuple &¶ms, std::index_sequence< Indexes... >)
static constexpr std::size_t next_index
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.
static constexpr std::size_t next_index
special_exact_fixed_size_fragment_clause_t(const char(&fragment)[Size])
virtual ~router_entry_t()=default
static constexpr std::size_t next_index
generic_easy_parser_router_t & operator=(generic_easy_parser_router_t &&)=default
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.
generic_easy_parser_router_t()=default
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, optional_t< Value_Type > >::type opt_value(const Parameter_Container ¶ms, string_view_t key)
Gets the value of a parameter specified by key wrapped in optional_t<Value_Type> if parameter exists ...