Documentation ¶
Index ¶
- func New(options ...Option) route.MiddlewareFunc
- type Option
- func AllowCredentials(allowCredentials bool) Option
- func AllowHeaders(allowHeaders []string) Option
- func AllowMethods(allowMethods []string) Option
- func AllowOrigins(allowOrigins []string) Option
- func ExposeHeaders(exposeHeaders []string) Option
- func MaxAge(maxAge int) Option
- func Skipper(skipper route.Skipper) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*Options)
func AllowCredentials ¶
func AllowHeaders ¶
func AllowMethods ¶
func AllowOrigins ¶
func ExposeHeaders ¶
type Options ¶
type Options struct { // Skipper defines a function to skip middleware. Skipper route.Skipper // AllowOrigin defines a list of origins that may access the resource. // Optional. Default value []string{"*"}. AllowOrigins []string `yaml:"allow_origins"` // AllowMethods defines a list methods allowed when accessing the resource. // This is used in response to a preflight request. // Optional. Default value DefaultCORSConfig.AllowMethods. AllowMethods []string `yaml:"allow_methods"` // AllowHeaders defines a list of request headers that can be used when // making the actual request. This in response to a preflight request. // Optional. Default value []string{}. AllowHeaders []string `yaml:"allow_headers"` // AllowCredentials indicates whether or not the response to the request // can be exposed when the credentials flag is true. When used as part of // a response to a preflight request, this indicates whether or not the // actual request can be made using credentials. // Optional. Default value false. AllowCredentials bool `yaml:"allow_credentials"` // ExposeHeaders defines a whitelist headers that clients are allowed to // access. // Optional. Default value []string{}. ExposeHeaders []string `yaml:"expose_headers"` // MaxAge indicates how long (in seconds) the results of a preflight request // can be cached. // Optional. Default value 0. MaxAge int `yaml:"max_age"` }
Options defines the config for CORS middleware.
func GetDefaultOptions ¶
func GetDefaultOptions() Options
Click to show internal directories.
Click to hide internal directories.