Documentation
¶
Overview ¶
Package cors provides handlers to enable CORS support.
Index ¶
- type Options
- func (o *Options) Allow(res http.ResponseWriter, req *http.Request, next http.HandlerFunc)
- func (o *Options) Header(origin string) (headers map[string]string)
- func (o *Options) IsOriginAllowed(origin string) (allowed bool)
- func (o *Options) PreflightHeader(origin, rMethod, rHeaders string) (headers map[string]string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options 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
}
Options represents Access Control options.
func (*Options) Allow ¶
func (o *Options) Allow(res http.ResponseWriter, req *http.Request, next http.HandlerFunc)
Allow enables CORS for requests those match the provided options.
func (*Options) IsOriginAllowed ¶
IsOriginAllowed looks up if the origin matches one of the patterns generated from Options.AllowOrigins patterns.
Click to show internal directories.
Click to hide internal directories.