Skip to content
Download

badRequest

mach::badRequest

Creates a Bad Request response.

Creates a 400 Bad Request response, optionally containing the specified value.

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

A Bad Request reply containing the specified value.

A Bad Request reply containing the specified string.

A Bad Request 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::badRequest(error);
return mach::badRequest("Invalid request.");
return mach::badRequest();
Name Description
Reply Represents the result of an HTTP endpoint.
ControllerBase::badRequest Creates a Bad Request response from a controller.