![]() |
boost::taar::response_builder — Fluent builder around any value that response_from can convert.
// In header: <boost/taar/core/response_builder.hpp> class response_builder { public: // public member functions template<typename... ArgsType> response_builder(ArgsType &&...); auto && set_version(unsigned); auto && set_version(unsigned); auto && set_status(boost::beast::http::status); auto && set_status(boost::beast::http::status); auto && insert_header(std::string_view, std::string_view const &); auto && insert_header(std::string_view, std::string_view const &); auto && insert_header(boost::beast::http::field, std::string_view const &); auto && insert_header(boost::beast::http::field, std::string_view const &); auto && set_header(std::string_view, std::string_view const &); auto && set_header(std::string_view, std::string_view const &); auto && set_header(boost::beast::http::field, std::string_view const &); auto && set_header(boost::beast::http::field, std::string_view const &); boost::beast::http::message_generator get_response(); };
Wrap an existing body value (a std::string, a boost::json::value, a boost::beast::http::response, etc.), then chain set_status, set_version, set_header, and insert_header on the result before consuming the final response with get_response, or returning the builder from a REST handler, in which case the conversion is automatic:
return taar::response_builder(boost::json::value{ {"ok", true} }) .set_status(http::status::created) .set_header(http::field::cache_control, "no-store");
Member functions return a reference to allow chaining; the rvalue overloads return a moved-from copy so the temporary can be returned directly.
response_builder public member functionstemplate<typename... ArgsType> response_builder(ArgsType &&... args);Construct around a value that response_from can convert.
auto && set_version(unsigned version);Set the HTTP version (
10 or 11). auto && set_version(unsigned version);Set the HTTP version (
10 or 11). auto && set_status(boost::beast::http::status status);Set the response status.
auto && set_status(boost::beast::http::status status);Set the response status.
auto && insert_header(std::string_view name, std::string_view const & value);Add a header field, keeping fields of the same name.
auto && insert_header(std::string_view name, std::string_view const & value);Add a header field, keeping fields of the same name.
auto && insert_header(boost::beast::http::field field, std::string_view const & value);Add a header field, keeping fields of the same name.
auto && insert_header(boost::beast::http::field field, std::string_view const & value);Add a header field, keeping fields of the same name.
auto && set_header(std::string_view name, std::string_view const & value);Set a header field, replacing fields of the same name.
auto && set_header(std::string_view name, std::string_view const & value);Set a header field, replacing fields of the same name.
auto && set_header(boost::beast::http::field field, std::string_view const & value);Set a header field, replacing fields of the same name.
auto && set_header(boost::beast::http::field field, std::string_view const & value);Set a header field, replacing fields of the same name.
boost::beast::http::message_generator get_response();Consume the builder and return a Beast message generator.