Skip to content

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

Macro

AuthMiddleware(_:using:)

Injects an authenticated handler parameter using middleware resolved from its controller.
@attached(peer) macro AuthMiddleware<T, Controller>(_ authenticationType: T.Type, using middleware: (Controller) -> any Middleware) where T : Authenticatable

Overview

Pass a key-path literal such as \Self.authentication, or a factory such as { (controller: Self) in UserAuthenticator(databases: controller.databases) }. The generated boot(routes:) evaluates the factory with the controller instance.