Skip to content

Commit 63689a5

Browse files
authored
Add docc comment about middleware application (#745)
1 parent 8220370 commit 63689a5

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

Sources/Hummingbird/Router/RouteCollection.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public final class RouteCollection<Context: RequestContext>: RouterMethods {
4040
}
4141

4242
/// Add middleware to RouteCollection
43+
///
44+
/// This middleware will only be applied to endpoints added after this call.
45+
/// - Parameter middleware: Middleware we are adding
4346
@discardableResult public func add(middleware: any MiddlewareProtocol<Request, Response, Context>) -> Self {
4447
self.middlewares.add(middleware)
4548
return self

Sources/Hummingbird/Router/RouterGroup.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public struct RouterGroup<Context: RequestContext>: RouterMethods {
4141
}
4242

4343
/// Add middleware to RouterGroup
44+
///
45+
/// This middleware will only be applied to endpoints added after this call.
46+
/// - Parameter middleware: Middleware we are adding
4447
@discardableResult public func add(middleware: any MiddlewareProtocol<Request, Response, Context>) -> RouterGroup<Context> {
4548
self.middlewares.add(middleware)
4649
return self

Sources/Hummingbird/Router/RouterMethods.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public protocol RouterMethods<Context>: _HB_SendableMetatype {
3434
) -> Self where Responder.Context == Context
3535

3636
/// add middleware
37+
///
38+
/// This middleware will only be applied to endpoints added after this call.
39+
/// - Parameter middleware: Middleware we are adding
3740
func add(middleware: any MiddlewareProtocol<Request, Response, Context>) -> Self
3841
}
3942

@@ -123,6 +126,8 @@ extension RouterMethods {
123126
/// ```
124127
/// This gives a slight performance boost over adding them individually.
125128
///
129+
/// The middleware will only be applied to endpoints added after this call.
130+
///
126131
/// - Parameter buildMiddlewareStack: Middleware stack result builder
127132
/// - Returns: router
128133
@discardableResult public func addMiddleware(

0 commit comments

Comments
 (0)