cors

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(options ...Options) gear.Middleware

New creates a middleware to provide CORS support for gear.

Types

type Options

type Options struct {
	// AllowOrigins defines the origins which will be allowed to access
	// the resource. Default value is []string{"*"} .
	AllowOrigins []string
	// AllowMethods defines the methods which will be allowed to access
	// the resource. It is used in handling the preflighted requests.
	// Default value is []string{"GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"} .
	AllowMethods []string
	// AllowOriginsValidator validates the request Origin by validator
	// function.The validator function accpects an `*gear.Context` and returns the
	// Access-Control-Allow-Origin value. If the validator is set, then
	// AllowMethods will be ignored.
	AllowOriginsValidator func(origin string, ctx *gear.Context) string
	// AllowHeaders defines the headers which will be allowed in the actual
	// request, It is used in handling the preflighted requests.
	AllowHeaders []string
	// ExposeHeaders defines the allowed headers that client could send when
	// accessing the resource.
	ExposeHeaders []string
	// MaxAge defines the max age that the preflighted requests can be cached.
	MaxAge time.Duration
	// Credentials defines whether or not the response to the request
	// can be exposed.
	Credentials bool
}

Options is cors middleware options.

Jump to

Keyboard shortcuts

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