Vapor Documentation Beta

Class CORSMiddleware

public final class CORSMiddleware: Middleware

Middleware that adds support for CORS settings in request responses. For configuration of this middleware please use the CORSMiddleware.Configuration object.

%3 CORSMiddleware CORSMiddleware Middleware Middleware CORSMiddleware->Middleware

Nested Types

CORSMiddleware.AllowOriginSetting

Option for the allow origin header in responses for CORS requests.

CORSMiddleware.Configuration

Configuration used for populating headers in response for CORS requests.

Conforms To

Middleware

Middleware is placed between the server and your router. It is capable of mutating both incoming requests and outgoing responses. Middleware can choose to pass requests on to the next Middleware in a chain, or they can short circuit and return a custom Response if desired.

Initializers

init(configuration:​)

public init(configuration: Configuration = .default())

Creates a CORS middleware with the specified configuration.

Parameters

configuration Configuration

Configuration used for populating headers in response for CORS requests.

Properties

configuration

let configuration: Configuration

Configuration used for populating headers in response for CORS requests.

Methods

respond(to:​chaining​To:​)

public func respond(to request: Request, chainingTo next: Responder) -> EventLoopFuture<Response>

See Middleware.