Skip to content
Download

ok

mach::ok

Creates an OK response.

Creates a 200 OK response, optionally containing the specified value.

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

An OK reply containing the specified value.

An OK reply containing the specified string.

An OK reply with no value.

Parameter Description
T The type of the response body.
Parameter Description
value The response body.
Parameter Description
value The response body.

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

return mach::ok(user);
return mach::ok("Hello from Mach!");
return mach::ok();
Name Description
Reply Represents the result of an HTTP endpoint.
ControllerBase::ok Creates an OK response from a controller.