![]() |
boost::taar::matcher::header_t — A placeholder that produces matchers over individual request headers.
// In header: <boost/taar/matcher/header.hpp> template<typename FieldsType = boost::beast::http::fields> struct header_t { // types typedef boost::beast::http::request_header< FieldsType > request_type; // The request type these matchers accept. // member classes/structs/unions // A handle to a particular header by key. template<typename KeyType> struct header_item { // friend functions auto exist(header_item); // public data members KeyType key; // The header key this item refers to. }; // public member functions auto operator()(boost::beast::http::field) const; auto operator()(std::string) const; };
header_t is not used directly; call its function-call operator with a well-known boost::beast::http::field value or a string field name to obtain a header_item, then compose that with the equality operators or with the free function exist().
using boost::taar::matcher::header; namespace http = boost::beast::http; auto is_json = header(http::field::content_type) == "application/json"; auto has_auth = exist(header("X-Auth"));
The produced operand carries header_eq_constraint, header_ne_constraint, or header_exists_constraint metadata with the field key (as a header_key variant) and the constrained value in its captures tuple. Existence matchers leave the captured value empty.
typename FieldsType = boost::beast::http::fields
The Beast HTTP fields container of the request to inspect. Defaults to boost::beast::http::fields.
header_t public member functionsauto operator()(boost::beast::http::field field) const;Build a header_item for a well-known Beast field.
auto operator()(std::string field) const;Build a header_item for an arbitrary header name.