Configuration

class Configuration

CORS feature configuration

Constructors

Link copied to clipboard
fun Configuration()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun allowHeaders(predicate: (String) -> Boolean)

Allow headers that match predicate

Link copied to clipboard
fun allowHeadersPrefixed(headerPrefix: String)

Allow headers prefixed with headerPrefix

Link copied to clipboard
fun allowXHttpMethodOverride()

Allow to send X-Http-Method-Override header

Link copied to clipboard
fun anyHost()

Allow requests from any host

Link copied to clipboard
fun exposeHeader(header: String)

Allow to expose header. It adds the header to Access-Control-Expose-Headers if it is not a simple response header.

Link copied to clipboard
fun exposeXHttpMethodOverride()

Allow to expose X-Http-Method-Override header

Link copied to clipboard
fun header(header: String)

Allow sending header

Link copied to clipboard
fun host(host: String, schemes: List<String> = listOf("http"), subDomains: List<String> = emptyList())

Allow requests from the specified domains and schemes. A wildcard is supported for either the host or any subdomain. If you specify a wildcard in the host, you cannot add specific subdomains. Otherwise you can mix wildcard and non-wildcard subdomains as long as the wildcard is always in front of the domain, e.g. *.sub.domain.com but not sub.*.domain.com.

Link copied to clipboard
fun method(method: HttpMethod)

Please note that CORS operates ONLY with REAL HTTP methods and will never consider overridden methods via X-Http-Method-Override. However you can add them here if you are implementing CORS at client side from the scratch that you generally don't need to do.

Properties

Link copied to clipboard
var allowCredentials: Boolean = false

Allow sending credentials

Link copied to clipboard
var allowNonSimpleContentTypes: Boolean = false

Allow sending requests with non-simple content-types. The following content types are considered simple:

Link copied to clipboard
var allowSameOrigin: Boolean = true

Allow requests from the same origin

Link copied to clipboard
val exposedHeaders: MutableSet<String>

Exposed HTTP headers that could be accessed by a client

Link copied to clipboard
val headerPredicates: MutableList<(String) -> Boolean>

If present represents the prefix for headers which are permitted in cors requests.

Link copied to clipboard
val headers: MutableSet<String>

Allowed CORS headers

Link copied to clipboard
val hosts: MutableSet<String>

Allowed CORS hosts

Link copied to clipboard
var maxAge: Duration

Max-Age for cached CORS options

Link copied to clipboard
var maxAgeInSeconds: Long

Duration in seconds to tell the client to keep the host in a list of known HSTS hosts.

Link copied to clipboard
val methods: MutableSet<HttpMethod>

Allowed HTTP methods

Extensions

Link copied to clipboard
var CORS.Configuration.maxAge: Duration
Link copied to clipboard

Duration to tell the client to keep CORS options.