Boost C++ Libraries

PrevUpHomeNext

Struct template target_t

boost::taar::matcher::target_t — A placeholder that produces matchers over the request target (path).

Synopsis

// In header: <boost/taar/matcher/target.hpp>

template<typename FieldsType = boost::beast::http::fields> 
struct target_t {
  // types
  typedef boost::beast::http::request_header< FieldsType > request_type;  // The request type these matchers accept. 

  // friend functions
  auto operator==(target_t, std::string_view);
};

Description

Compose with == and != against a path template:

using boost::taar::matcher::target;

auto exact   = target == "/api/version";
auto by_id   = target == "/users/{id}";
auto bucket  = target == "/files/{*path}";
auto any     = target == "/{*}";

Path templates use the following grammar:

  • Literal segments are matched verbatim.

  • {name} matches one segment and stores it in context::path_args under name.

  • {*name} (greedy) matches zero or more segments joined with / and stores the result under name.

  • {*} is shorthand for a greedy capture stored under the key "*".

On a successful match the captured arguments are written to boost::taar::matcher::context::path_args, where the taar::handler::path_arg argument provider can later read them.

The produced operand carries target_constraint metadata with the raw* template string (unparsed) in its captures tuple. Auxiliary generators (OpenAPI, MCP, ...) read the template verbatim from the captures; the parsed-segment representation used for matching at runtime remains an implementation detail.

Template Parameters

  1. typename FieldsType = boost::beast::http::fields

    The Beast HTTP fields container of the request to inspect. Defaults to boost::beast::http::fields.

target_t friend functions

  1. auto operator==(target_t, std::string_view target_template);
    Build a matcher for path-template target_template.

PrevUpHomeNext