Back to Kitura

RouterMiddlewareGenerator

docs/docsets/Kitura.docset/Contents/Resources/Documents/Classes/RouterMiddlewareGenerator.html

3.0.11.3 KB
Original Source

RouterMiddlewareGenerator

public class RouterMiddlewareGenerator : RouterMiddleware

Create an on the fly RouterMiddleware from a RouterHandler closure.

`

                init(handler:)
                `

Initialize a RouterMiddlewareGenerator instance

Declaration

Swift

public init(handler: @escaping RouterHandler)

Parameters

| handler |

The closure that is of the type RouterHandler to be called to handle requests

|

`

                handle(request:response:next:)
                `

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 used to work with the incoming HTTP request.

| | response |

The RouterResponse object used to respond to the HTTP request.

| | next |

The closure called to invoke the next handler or middleware associated with the request.

|