use
mach::AppBuilder::use
Registers a middleware.
Description
Section titled “Description”Registers a middleware in the application’s request pipeline.
Syntax
Section titled “Syntax”template <typename T, typename... Deps>AppBuilder& use();Return Value
Section titled “Return Value”A reference to the current AppBuilder instance.
Template Parameters
Section titled “Template Parameters”| Parameter | Description |
|---|---|
T |
The controller type to register. |
Deps |
The dependency types used to construct the controller. |
Exceptions
Section titled “Exceptions”| Exception | Condition |
|---|---|
std::logic_error |
Thrown if the middleware type has already been registered or is reserved by the framework. |
Remarks
Section titled “Remarks”Middlewares are registered with a scoped lifetime. A single middleware instance is created for each request.
Thread Safety
Section titled “Thread Safety”This method is not thread-safe and should only be called during application configuration, before the application starts handling requests.
Example
Section titled “Example”builder.use<LoggingMiddleware, mach::Logger>();See Also
Section titled “See Also”| Name | Description |
|---|---|
Next |
Invokes the next middleware in the pipeline. |