Skip to content

Instance Method

use(_:at:)

Adds a pre-initialized Middleware instance.
mutating func use(_ middleware: any Middleware, at position: Middlewares.Position = .end)

Discussion

app.middleware.use(fooMiddleware)

Warning

Ensure the Middleware is thread-safe when using this method. Otherwise, use the type-based method and register the Middleware using factory method to Services.