query
mach::Request::query
Returns the value of a query parameter.
Description
Section titled “Description”Returns the value of the query parameter with the specified name.
Syntax
Section titled “Syntax”[[nodiscard]] std::optional<std::string_view> query(std::string_view name) const;Return Value
Section titled “Return Value”The query parameter value, or std::nullopt if the request does not contain the specified query parameter.
Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
name |
The name of the query parameter to return. |
Exceptions
Section titled “Exceptions”| Exception | Condition |
|---|---|
std::bad_alloc |
Thrown if memory allocation fails. |
Remarks
Section titled “Remarks”Query parameter names are case-sensitive.
Thread Safety
Section titled “Thread Safety”This function is thread-safe.
Example
Section titled “Example”if (auto page = request().query("page")) { // Use *page...}See Also
Section titled “See Also”| Name | Description |
|---|---|
containsQuery |
Checks whether the request contains a query parameter. |
query<T> |
Returns a query parameter converted to a specified type. |