cors

package module
v0.0.0-...-6bc64f6 Latest Latest
Warning

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

Go to latest
Published: May 28, 2015 License: Apache-2.0 Imports: 6 Imported by: 4

README

cors

hador cors filter

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Allow

func Allow(opts *CORSOptions) hador.FilterFunc

Allow enables CORS for requests those match the provided options.

Types

type CORSOptions

type CORSOptions struct {
	// If set, all origins are allowed.
	AllowAllOrigins bool
	// A list of allowed origins. Wild cards and FQDNs are supported.
	AllowOrigins []string
	// If set, allows to share auth credentials such as cookies.
	AllowCredentials bool
	// A list of allowed HTTP methods.
	AllowMethods []string
	// A list of allowed HTTP headers.
	AllowHeaders []string
	// A list of exposed HTTP headers.
	ExposeHeaders []string
	// Max age of the CORS headers.
	MaxAge time.Duration
}

CORSOptions represents Access Control options.

func (*CORSOptions) Header

func (o *CORSOptions) Header(origin string) (headers map[string]string)

Header converts options into CORS headers.

func (*CORSOptions) IsOriginAllowed

func (o *CORSOptions) IsOriginAllowed(origin string) (allowed bool)

IsOriginAllowed looks up if the origin matches one of the patterns generated from Options.AllowOrigins patterns.

func (*CORSOptions) PreflightHeader

func (o *CORSOptions) PreflightHeader(origin, rMethod, rHeaders string) (headers map[string]string)

PreflightHeader converts options into CORS headers for a preflight response.

Jump to

Keyboard shortcuts

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