cors

package
v3.0.0-...-e1df10c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cors provides a handler for handling CORS.

Index

Constants

This section is empty.

Variables

View Source
var AllowAll = Options{
	AllowOrigins: "*",
	AllowHeaders: "*",
	AllowMethods: "*",
}

AllowAll is the option that allows all origins, headers, and methods.

Functions

func Handler

func Handler(opts Options) routing.Handler

Handler creates a routing handler that adds appropriate CORS headers according to the specified options and the request.

Types

type Options

type Options struct {
	// the allowed origins (separated by commas). Use an asterisk (*) to indicate allowing all origins, "null" to indicate disallowing any.
	AllowOrigins string
	// whether the response to request can be exposed when the omit credentials flag is unset, or whether the actual request can include user credentials.
	AllowCredentials bool
	// the HTTP methods (separated by commas) that can be used during the actual request. Use an asterisk (*) to indicate allowing any method.
	AllowMethods string
	// the HTTP headers (separated by commas) that can be used during the actual request. Use an asterisk (*) to indicate allowing any header.
	AllowHeaders string
	// the HTTP headers (separated by commas) that are safe to expose to the API of a CORS API specification
	ExposeHeaders string
	// Max amount of seconds that the results of a preflight request can be cached in a preflight result cache.
	MaxAge time.Duration
	// contains filtered or unexported fields
}

Options specifies how the CORS handler should respond with appropriate CORS headers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL