chttpserver · Section 3
chttpsvr_req_context
NAME
chttpsvr_req_context - read a value that a middleware attached to a request
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/chttpserver.h> void *chttpsvr_req_context(const chttpsvr_req *req, const void *key);
DESCRIPTION
Returns the value that chttpsvr_req_set_context attached to req under key. Keys are compared by address and nothing else. The values can be read until the chain of the request returns; see chttpsvr_req_set_context(3) for that lifetime.
PARAMETERS
req The request. key The key, compared by address.
RETURN VALUE
The value attached under key. NULL when req or key is NULL, when no value is attached under key, and also when the stored value is NULL.
THREAD SAFETY
Call it only on the thread that runs the chain of the request, and only while that chain runs. It takes no lock.
EXAMPLES
static const char trace_key; const char *trace = chttpsvr_req_context(req, &trace_key); if (trace) chttpsvr_resp_set_header(resp, "x-trace-id", trace);
SEE ALSO
chttpsvr_req_set_context(3), chttpsvr_use(3), chttpsvr_router_use(3)