Skip to content
Download

mapHead

mach::App::mapGet

Registers a handler for HTTP HEAD requests.

Registers a handler for HTTP HEAD requests matching the specified route pattern.

template <typename THandler>
void mapHead(std::string_view pattern, THandler&& handler);
Name Description
pattern The route pattern to match (e.g. “/api/users”).
handler The handler invoked when a request matches the route pattern.
Exception Condition
std::logic_error Thrown if a route with the same HTTP method and route pattern has already been registered.
  • The endpoint is registered immediately when this function is called.
  • OPTIONS requests are handled automatically by the framework.

This function is not thread-safe. Concurrent route registration must be synchronized externally.

app.mapHead("/health", [] {
return mach::ok();
});
Name Description
mapGet Registers a handler for HTTP GET requests.
mapPost Registers a handler for HTTP POST requests.
mapPut Registers a handler for HTTP PUT requests.
mapPatch Registers a handler for HTTP PATCH requests.
mapDelete Registers a handler for HTTP DELETE requests.