Skip to content

Instance Method

group(_:configure:)

Creates a new Router wrapped in the supplied array of Middleware.
func group(_ middleware: [any Middleware], configure: (any RoutesBuilder) throws -> ()) rethrows

Parameters

middleware

Array of [Middleware] to wrap Router in.

configure

Closure to configure the newly created Router.

Discussion

router.group([FooMiddleware(), BarMiddleware()]) { group in
    // all routes added will be wrapped by Foo & Bar middleware
    group.get(...) { ... }
}