Skip to content

You're viewing documentation for a pre-release version. View the latest stable version

Instance Method

use(_:at:)

Adds a pre-initialized Middleware instance.
mutating func use(_ middleware: any Middleware, at position: 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.