CORS

public class CORS : RouterMiddleware

Cross-Origin Resource Sharing CORS middleware.

  • Initialize an instance of CORS.

    Declaration

    Swift

    public init(options: Options)

    Parameters

    options

    The options to configure CORS.

  • Handle an incoming request by setting the CORS headers in the response.

    Throws

    Any ErrorType. If an error is thrown, processing of the request is stopped, the error handlers, if any are defined, will be invoked, and the user will get a response with a status code of 500.

    Declaration

    Swift

    public func handle(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) throws

    Parameters

    request

    The RouterRequest object used to get information about the request.

    response

    The RouterResponse object used to respond to the request.

    next

    The closure to invoke to enable the Router to check for other handlers or middleware to work with this request.