![]() |
boost::taar::handler::attribute_arg — Argument provider that reads a request attribute of type T.
// In header: <boost/taar/handler/rest_arg.hpp> template<typename T> struct attribute_arg { // public member functions std::string name() const; taar::result< T > operator()(boost::beast::http::request_header<> const &, matcher::context const &) const; };
Returns a copy of the value stored under T in boost::taar::matcher::context::attributes, typically by a session interceptor or a handler::guard check, or error::argument_not_found when none is stored, so a std::optional<T> parameter or with_default makes it optional. It reads only the matcher context, so it works in rest(...), jsonrpc::endpoint::method(...) and mcp::endpoint::tool(...) alike. It is not a client-supplied input: OpenAPI omits it, and JSON-RPC and MCP leave it out of the parameter list and the input schema.
struct principal { std::string user; }; session.register_request_handler( method == http::verb::get && target == "/me", taar::handler::rest( [](principal const& p) { return p.user; }, taar::handler::attribute_arg<principal>()));
attribute_arg public member functionsstd::string name() const;The attribute type's name, for diagnostics.
taar::result< T > operator()(boost::beast::http::request_header<> const &, matcher::context const & context) const;