Skip to content
Download

use

mach::AppBuilder::use

Registers a middleware.

Registers a middleware in the application’s request pipeline.

template <typename T, typename... Deps>
AppBuilder& use();

A reference to the current AppBuilder instance.

Parameter Description
T The controller type to register.
Deps The dependency types used to construct the controller.
Exception Condition
std::logic_error Thrown if the middleware type has already been registered or is reserved by the framework.

Middlewares are registered with a scoped lifetime. A single middleware instance is created for each request.

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

builder.use<LoggingMiddleware, mach::Logger>();
Name Description
Next Invokes the next middleware in the pipeline.