Skip to content
Download

query

mach::Request::query

Returns the value of a query parameter.

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

[[nodiscard]] std::optional<std::string_view> query(std::string_view name) const;

The query parameter value, or std::nullopt if the request does not contain the specified query parameter.

Parameter Description
name The name of the query parameter to return.
Exception Condition
std::bad_alloc Thrown if memory allocation fails.

Query parameter names are case-sensitive.

This function is thread-safe.

if (auto page = request().query("page")) {
// Use *page...
}
Name Description
containsQuery Checks whether the request contains a query parameter.
query<T> Returns a query parameter converted to a specified type.