Skip to content
Download

unauthorized

mach::unauthorized

Creates an Unauthorized response.

Creates a 401 Unauthorized response, optionally containing the specified value.

// (1)
template <typename T>
[[nodiscard]] mach::Reply<T> unauthorized(T value);
// (2)
[[nodiscard]] mach::Reply<std::string> unauthorized(const char* value);
// (3)
template <typename T = void>
[[nodiscard]] mach::Reply<T> unauthorized();

An Unauthorized reply containing the specified value.

An Unauthorized reply containing the specified string.

An Unauthorized reply with no value.

Parameter Description
T The type of the response body.
Parameter Description
T The reply value type used to match the endpoint’s return type. Defaults to void.
Parameter Description
value The response body.
Parameter Description
value The response body.

Overload (2) converts the specified value to a std::string.

return mach::unauthorized(error);
return mach::unauthorized("Authentication required.");
return mach::unauthorized();
Name Description
Reply Represents the result of an HTTP endpoint.
ControllerBase::unauthorized Creates an Unauthorized response from a controller.