template<
typename Extra_Data_Factory = no_extra_data_factory_t>
class restinio::async_chain::growable_size_chain_t< Extra_Data_Factory >
A holder of variable-size chain of asynchronous handlers.
- Note
- Once a list of schedulers is filled and an instance of growable_size_chain_t is created that instance can't be changed: a new scheduler can't be added, and an old scheduler 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 (please note that this is simplified example without actual asynchronous code, all schedulers work as synchronous handlers):
};
{
...
}
{
...
}
{
...
}
if(
config.force_headers_checking())
if(
config.force_user_authentification())
.address(...)
.port(...)
.request_handler(
builder.release())
);
A builder of an instance of growable_size_chain.
void add(Scheduler &&scheduler)
Add a new scheduler to the chain.
A holder of variable-size chain of asynchronous handlers.
constexpr schedule_result_t ok() noexcept
Helper function to be used if scheduling was successful.
void next(unique_async_handling_controller_t< Extra_Data_Factory > controller)
Command to try to switch to the next handler in an async chain.
schedule_result_t
Type for return value of a scheduler in a chain.
std::unique_ptr< async_handling_controller_t< Extra_Data_Factory > > unique_async_handling_controller_t
Short alias for unique_ptr to async_handling_controller.
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.
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.
Usage example for the case when some extra-data is incorporated into a request object: (please note that this is simplified example without actual asynchronous code, all schedulers work as synchronous handlers):
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>;
};
{
...
...
}
{
...
...
}
{
auto &
field_values = std::get<my_extra_data_factory::request_specific_fields_t>(
req->extra_data());
auto &
user_info = std::get<my_extra_data_factory::user_info_t>(
req->extra_data());
...
}
if(
config.force_headers_checking())
if(
config.force_user_authentification())
.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.
- Template Parameters
-
Extra_Data_Factory | The type of extra-data-factory specified in the server's traits. |
- Since
- v.0.7.0
Definition at line 180 of file growable_size.hpp.