RouterMiddlewareGenerator
public class RouterMiddlewareGenerator : RouterMiddleware
Create an on the fly RouterMiddleware from a RouterHandler closure.
-
Initialize a
RouterMiddlewareGeneratorinstanceDeclaration
Swift
public init(handler: @escaping RouterHandler)Parameters
handlerThe closure that is of the type
RouterHandlerto be called to handle requests -
Implementation of RouterMiddleware protocol. A simple wrapper around the closure that will handle the request.
Declaration
Swift
public func handle(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) throwsParameters
requestThe
RouterRequestobject used to work with the incoming HTTP request.responseThe
RouterResponseobject used to respond to the HTTP request.nextThe closure called to invoke the next handler or middleware associated with the request.
View on GitHub
RouterMiddlewareGenerator Class Reference