Skip to content
Download

routeParam

mach::Request::routeParam

Returns a route parameter.

Returns the value of the route parameter with the specified name.

[[nodiscard]] std::string_view routeParam(std::string_view name) const;

The route parameter value.

Parameter Description
name The name of the route parameter to return.
Exception Condition
std::bad_alloc Thrown if memory allocation fails.
std::out_of_range Thrown if the specified parameter does not exist.

This function is thread-safe.

Route parameter names are case-sensitive.

auto id = request().routeParam("id");
Name Description
routeParam<T> Returns a route parameter converted to a specified type.