template<typename Extra_Data_Factory = no_extra_data_factory_t>
class restinio::sync_chain::growable_size_chain_t< Extra_Data_Factory >
A holder of variable-size chain of synchronous handlers.
- Note
- Once a list of handler is filled and an instance of growable_size_chain_t is created that instance can't be changed: a new handler can't be added, and an old handler can be removed. The creation of growable_size_chain_t instance is performed by the help of growable_size_chain_t::builder_t class.
Usage example for the case when there is no extra-data in a request object.
};
{
...
}
{
...
}
{
...
}
if(
config.force_headers_checking())
builder.
add(headers_checker);
if(
config.force_user_authentification())
builder.
add(authentificator);
builder.
add(actual_handler);
on_thread_pool<my_traits>(16)
.address(...)
.port(...)
.request_handler(builder.
release())
);
A builder of an instance of growable_size_chain.
void add(Handler &&handler)
Add a new handler to the chain.
RESTINIO_NODISCARD std::unique_ptr< growable_size_chain_t > release() noexcept
Stop adding of new handlers and acquire the chain instance.
A holder of variable-size chain of synchronous handlers.
void run(asio_ns::io_context &ioctx, run_on_this_thread_settings_t< Traits > &&settings)
Helper function for running http server until ctrl+c is hit.
request_handling_status_t
Request handling status.
std::shared_ptr< request_t > request_handle_t
An alias for handle for incoming request without additional extra-data.
Usage example for the case when some extra-data is incorporated into a request object.
struct my_extra_data_factory {
struct request_specific_fields_t {...};
struct user_info_t {...};
using data_t = std::tuple<
std::optional<request_specific_fields_t>,
std::optional<user_info_t>>;
}
};
using extra_data_factory_t = my_extra_data_factory;
extra_data_factory>;
};
using my_request_handle_t =
const my_request_handle_t & req )
{
...
}
const my_request_handle_t & req )
{
...
}
const my_request_handle_t & req )
{
std::optional<my_extra_data_factory::request_specific_fields_t>>(req->extra_data());
std::optional<my_extra_data_factory::user_info_t>>(req->extra_data());
...
}
if(
config.force_headers_checking())
builder.
add(headers_checker);
if(
config.force_user_authentification())
builder.
add(authentificator);
builder.
add(actual_handler);
on_thread_pool<my_traits>(16)
.address(...)
.port(...)
.request_handler(builder.
release())
);
std::shared_ptr< generic_request_t< Extra_Data > > generic_request_handle_t
An alias for shared-pointer to incoming request.
Value_Type get(const router::route_params_t ¶ms, string_view_t key)
Cast named parameter value to a given type.
- Template Parameters
-
Extra_Data_Factory | The type of extra-data-factory specified in the server's traits. |
- Since
- v.0.6.13
- Examples
- sample/extra_data_factory/main.cpp.
Definition at line 158 of file growable_size.hpp.