Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(opts 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.
Click to show internal directories.
Click to hide internal directories.