Template Struct context_common¶
Defined in File context.h
Inheritance Relationships¶
Derived Types¶
public udho::context< AuxT, RequestT, ShadowT >(Template Struct context)public udho::context< AuxT, RequestT, void >(Template Struct context< AuxT, RequestT, void >)
Struct Documentation¶
-
template<typename
AuxT, typenameRequestT>
structudho::detail::context_common¶ Subclassed by udho::context< AuxT, RequestT, ShadowT >, udho::context< AuxT, RequestT, void >
Public Types
-
typedef context_common<AuxT, request_type>
self_type¶
-
typedef detail::context_impl<request_type>
impl_type¶
Public Functions
-
interaction_ &
interaction()¶
-
const request_type &
request() const¶ returns the boost beast HTTP request
-
template<class
Body, classFields>
voidpatch(boost::beast::http::message<false, Body, Fields> &res) const¶ patches the response with the headers added in the context from inside the callable
accesses the HTTP cookies
-
operator request_type() const¶ conversion operator to convert to the corresponding beast request type
-
template<udho::logging::status
Status>
voidlog(const udho::logging::message<Status> &msg) const¶ Logs a message to the logger attached with the server. A logging message can be passed to the
logmethod or theoperator<<can be used to log a message.ctx << udho::logging::messages::formatted::debug("data", "testing log functionality of %1% Hi %2%") % "Neel Basu" % 42; ctx << udho::logging::messages::formatted::info("data", "testing log functionality of %1% Hi %2%") % "Neel Basu" % 42; ctx << udho::logging::messages::formatted::warning("data", "testing log functionality of %1% Hi %2%") % "Neel Basu" % 42; ctx << udho::logging::messages::formatted::error("data", "testing log functionality of %1% Hi %2%") % "Neel Basu" % 42;
-
template<typename
AttachmentT>
voidattach(AttachmentT &attachment)¶ attaches a context with its server counter part
-
void
respond(udho::defs::response_type &response)¶ respond with a http status. The responded output will be put inside a beast HTTP response object and a content type header of type mime will be attached
-
template<typename
OutputT>
voidrespond(const OutputT &output, const std::string &mime)¶ the responded output will be put inside a beast HTTP response object and a content type header of type mime will be attached
-
template<typename
OutputT>
voidrespond(boost::beast::http::status s, const OutputT &output, const std::string &mime)¶ respond with a http status. The responded output will be put inside a beast HTTP response object and a content type header of type mime will be attached
-
void
status(boost::beast::http::status s)¶ set a status code for the HTTP response
-
std::string
target() const¶ target of the HTTP request including the
?if the request includes get parameters// https://localhost/user/profile?id=245 ctx.target() // /user/profile?id=245
-
std::string
path() const¶ path of the HTTP request before
?if any// https://localhost/user/profile?id=245 ctx.path() // /user/profile
-
const query_parser_type &
query() const¶ The get query of the HTTP request.
if(!ctx.query().has("type") || ctx.query().field<std::string>("type") == "json"){ // respond with JSON content }else if(ctx.query().field<std::string>("type") == "xml") // respond with xml content }
-
void
clear()¶
-
void
reroute(const std::string &path)¶ Internally reroute an HTTP request to another request
-
bool
rerouted() const¶ check whether this is a rerouted request or not
-
std::string
alt_path() const¶
-
std::string
render(const std::string &path) const¶ render a file in path
-
template<typename ...
DataT>
std::stringrender(const std::string &path, const DataT&... data) const¶ render a template in path
-
std::size_t
reroutes() const¶
-
detail::client_connection_wrapper<self_type>
client(udho::config<udho::client_options> options = udho::config<udho::client_options>())¶
-
boost::asio::io_service &
io()¶
-
typedef context_common<AuxT, request_type>