Loading...
Searching...
No Matches
traits.hpp
Go to the documentation of this file.
/*
restinio
*/
#pragma once
#include <restinio/request_handler.hpp>
#include <restinio/asio_timer_manager.hpp>
#include <restinio/null_logger.hpp>
#include <restinio/connection_state_listener.hpp>
#include <restinio/ip_blocker.hpp>
#include <restinio/default_strands.hpp>
#include <restinio/connection_count_limiter.hpp>
#include <restinio/utils/metaprogramming.hpp>
namespace restinio
{
namespace details
{
namespace valid_request_handler_type_check
{
template< typename, typename, typename = restinio::utils::metaprogramming::void_t<> >
struct valid_handler_type : public std::false_type {};
template< typename Handler, typename Extra_Data_Factory >
struct valid_handler_type<
Handler,
Extra_Data_Factory,
restinio::utils::metaprogramming::void_t<
std::enable_if_t<
std::is_same<
request_handling_status_t,
decltype(std::declval<Handler>()(
std::declval<
generic_request_handle_t<
typename Extra_Data_Factory::data_t
>
>()))
>::value,
bool
>
>
> : public std::true_type
{};
} /* namespace valid_request_handler_type_check */
//
// autodetect_request_handler_type
//
struct autodetect_request_handler_type {};
//
// actual_request_handler_type_detector
//
template<
typename Request_Handler,
typename Extra_Data_Factory >
struct actual_request_handler_type_detector
{
static_assert(
valid_request_handler_type_check::valid_handler_type<
Request_Handler,
Extra_Data_Factory
>::value,
"Request_Handler should be invocable with "
"generic_request_handle_t<Extra_Data_Factory::data_t>" );
using request_handler_t = Request_Handler;
};
template< typename Extra_Data_Factory >
struct actual_request_handler_type_detector<
autodetect_request_handler_type,
Extra_Data_Factory >
{
using request_handler_t = std::function<
request_handling_status_t(
generic_request_handle_t<typename Extra_Data_Factory::data_t>) >;
};
} /* namespace details */
//
// traits_t
//
template <
typename Timer_Manager,
typename Logger,
typename Request_Handler = details::autodetect_request_handler_type,
typename Strand = default_strand_t,
typename Socket = asio_ns::ip::tcp::socket >
struct traits_t
{
using http_methods_mapper_t = default_http_methods_t;
using connection_state_listener_t = connection_state::noop_listener_t;
using ip_blocker_t = ip_blocker::noop_ip_blocker_t;
using timer_manager_t = Timer_Manager;
using logger_t = Logger;
using request_handler_t = Request_Handler;
using strand_t = Strand;
using stream_socket_t = Socket;
static constexpr bool use_connection_count_limiter = false;
using extra_data_factory_t = no_extra_data_factory_t;
};
//
// request_handler_type_from_traits_t
//
template< typename Traits >
using request_handler_type_from_traits_t =
typename details::actual_request_handler_type_detector<
typename Traits::request_handler_t,
typename Traits::extra_data_factory_t
>::request_handler_t;
//
// generic_request_type_from_traits_t
//
template< typename Traits >
using generic_request_type_from_traits_t =
generic_request_t< typename Traits::extra_data_factory_t::data_t >;
//
// single_thread_traits_t
//
template <
typename Timer_Manager,
typename Logger,
typename Request_Handler = details::autodetect_request_handler_type >
using single_thread_traits_t =
traits_t< Timer_Manager, Logger, Request_Handler, noop_strand_t >;
//
// default_traits_t
//
using default_traits_t = traits_t< asio_timer_manager_t, null_logger_t >;
using default_single_thread_traits_t = single_thread_traits_t<
asio_timer_manager_t,
null_logger_t >;
} /* namespace restinio */
asio_timer_manager.hpp
restinio::asio_timer_manager_t
Timer factory implementation using asio timers.
Definition: asio_timer_manager.hpp:31
restinio::default_http_methods_t
The default implementation for http_method_mapper.
Definition: http_headers.hpp:1833
restinio::generic_request_t
HTTP Request data.
Definition: request_handler.hpp:209
restinio::null_logger_t
No operation logger.
Definition: null_logger.hpp:23
connection_count_limiter.hpp
Stuff related to limits of active parallel connections.
connection_state_listener.hpp
Stuff related to connection state listeners.
default_strands.hpp
Typedefs for default strands.
ip_blocker.hpp
Stuff related to IP blockers.
metaprogramming.hpp
Various tools for C++ metaprogramming.
restinio::utils::metaprogramming::void_t
typename make_void< Ts... >::type void_t
Definition: metaprogramming.hpp:28
restinio
Definition: asio_include.hpp:21
restinio::default_strand_t
asio_ns::strand< default_asio_executor > default_strand_t
A typedef for the default strand type.
Definition: default_strands.hpp:23
restinio::generic_request_handle_t
std::shared_ptr< generic_request_t< Extra_Data > > generic_request_handle_t
An alias for shared-pointer to incoming request.
Definition: request_handler.hpp:455
restinio::request_handling_status_t
request_handling_status_t
Request handling status.
Definition: common_types.hpp:26
restinio::request_handler_type_from_traits_t
typename details::actual_request_handler_type_detector< typename Traits::request_handler_t, typename Traits::extra_data_factory_t >::request_handler_t request_handler_type_from_traits_t
A metafunction for extraction a request-handler type from server's traits.
Definition: traits.hpp:379
null_logger.hpp
request_handler.hpp
restinio::connection_state::noop_listener_t
The default no-op state listener.
Definition: connection_state_listener.hpp:274
restinio::details::actual_request_handler_type_detector< autodetect_request_handler_type, Extra_Data_Factory >::request_handler_t
std::function< request_handling_status_t(generic_request_handle_t< typename Extra_Data_Factory::data_t >) > request_handler_t
Definition: traits.hpp:131
restinio::details::actual_request_handler_type_detector
A metafunction for the detection of type of a request-handler.
Definition: traits.hpp:106
restinio::details::actual_request_handler_type_detector::request_handler_t
Request_Handler request_handler_t
Definition: traits.hpp:115
restinio::details::autodetect_request_handler_type
A special type to be used as indicator that the type of a request handler should be automatically det...
Definition: traits.hpp:92
restinio::details::valid_request_handler_type_check::valid_handler_type
Definition: traits.hpp:31
restinio::ip_blocker::noop_ip_blocker_t
The default no-op IP-blocker.
Definition: ip_blocker.hpp:94
restinio::no_extra_data_factory_t
The default extra-data-factory to be used in server's traits if a user doesn't specify own one.
Definition: request_handler.hpp:77
restinio::traits_t
Definition: traits.hpp:147
restinio::traits_t::timer_manager_t
Timer_Manager timer_manager_t
Definition: traits.hpp:249
restinio::traits_t::logger_t
Logger logger_t
Definition: traits.hpp:250
restinio::traits_t::stream_socket_t
Socket stream_socket_t
Definition: traits.hpp:253
restinio::traits_t::request_handler_t
Request_Handler request_handler_t
Definition: traits.hpp:251
restinio::traits_t::strand_t
Strand strand_t
Definition: traits.hpp:252
restinio::traits_t::use_connection_count_limiter
static constexpr bool use_connection_count_limiter
A flag that enables or disables the usage of connection count limiter.
Definition: traits.hpp:278