0001 import Foundation 0002 0003 /** 0004 Intercept and modify `Request`s and `Response`s 0005 using middleware. Create a class that conforms to 0006 the `Middleware` protocol, then append the class 0007 to the `Server`s `middleware` array. 0008 */ 0009 public protocol Middleware{ 0010 0011 /** 0012 Here is where you implement your custom `Middleware` 0013 logic. Look at the `SessionMiddleware` to see an 0014 example of `Middleware` being used. 0015 0016 Call `handler(request)` somewhere inside your custom 0017 handler to get the `Response` object. 0018 */ 0019 static func handle
Application+Route.swift:15 static var scopedMiddleware: [Middleware.Type] = []Application.swift:32 public var middleware: [Middleware.Type]SessionMiddleware.swift:1 class SessionMiddleware: Middleware {(handler: Request.Handler) -> Request.Handler 0020 0021 }
Application.swift:174 handler = middleware.handle(handler)