RouterMiddlewareGenerator
public class RouterMiddlewareGenerator: RouterMiddleware
Create an on the fly RouterMiddleware
from a RouterHandler
closure.
-
Initialize a
RouterMiddlewareGenerator
instanceDeclaration
Swift
public init(handler: @escaping RouterHandler)
Parameters
handler
The closure that is of the type
RouterHandler
to 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) throws
Parameters
request
The
RouterRequest
object that is used to work with the incoming request.response
The
RouterResponse
object used to send responses to the HTTP request.next
The closure to invoke to cause the router to inspect the path in the list of paths.