Skip to content
Download

mapPatch

mach::ControllerBuilder::mapPatch

Registers a PATCH handler.

Registers a PATCH endpoint for the controller.

// (1)
template <typename THandler>
ControllerBuilder<TController>& mapPatch(std::string_view pattern, THandler&& handler);
// (2)
template <typename THandler>
ControllerBuilder<TController>& mapPatch(THandler&& handler);

A reference to the current ControllerBuilder instance.

Parameter Description
THandler The type of the endpoint handler.
Parameter Description
pattern The route pattern to map.
handler The handler invoked for the endpoint.
Parameter Description
handler The handler invoked for the endpoint.
Exception Condition
std::logic_error Thrown if a route with the same method and pattern has already been registered.

In overload (2), the route pattern defaults to the controller’s route.

This method is not thread-safe and should only be called during controller configuration, before the application starts handling requests.

controller.mapPatch("/users/{id}", &UserController::updateUser);
controller.mapPatch(&UserController::updateUser);
Name Description
mapGet Registers a GET handler.
mapPost Registers a POST handler.
mapPut Registers a PUT handler.
mapDelete Registers a DELETE handler.
mapHead Registers a HEAD handler.