Documentation ¶
Index ¶
- Constants
- type CorsFilter
- func (cf *CorsFilter) HandleActualRequest(w http.ResponseWriter, r *http.Request)
- func (cf *CorsFilter) HandleCors(next http.Handler) http.Handler
- func (cf *CorsFilter) SetAllowCredentials(allow bool)
- func (cf *CorsFilter) SetAllowPvtNetwork(allow bool)
- func (cf *CorsFilter) SetAllowedHeaders(headers ...string)
- func (cf *CorsFilter) SetAllowedMethods(methods ...string)
- func (cf *CorsFilter) SetAllowedOrigins(origins ...string)
- func (cf *CorsFilter) SetExposeHeaders(headers ...string)
- func (cf *CorsFilter) SetMaxAge(maxAge int)
- func (cf *CorsFilter) SetPreFlightPassThrough(passThrough bool)
- func (cf *CorsFilter) SetResponseStatus(status int)
- type CorsOptions
Constants ¶
View Source
const ( AllowCredentials = "Access-Control-Allow-Credentials" AllowExposeHeaders = "Access-Control-Expose-Headers" AllowHeadersHeader = "Access-Control-Allow-Headers" AllowMethodsHeader = "Access-Control-Allow-Methods" AllowOriginHeader = "Access-Control-Allow-Origin" MaxAgeHeader = "Access-Control-Max-Age" ExposeHeaders = "Access-Control-Expose-Headers" AccessControlReqHeaders = "Access-Control-Request-Headers" AccessControlReqMethodHdr = "Access-Control-Request-Method" AccessControlPvtNetworkHdr = "Access-Control-Allow-Private-Network" OriginHeader = "Origin" VaryHeader = "Vary" AccessControlAllowAllOrigins = "*" // DefaultAccessControlMaxAge is the default value for the MaxAge field DefaultAccessControlMaxAge = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CorsFilter ¶
type CorsFilter struct { *CorsOptions PreFlightVary []string `json:"-"` AllowAllOrigins bool `json:"-" yaml:"-"` AllowAllMethods bool `json:"-" yaml:"-"` // contains filtered or unexported fields }
CorsFilter represents the CORS filter
func NewCorsFilter ¶
func NewCorsFilter(allowedOrigins ...string) *CorsFilter
NewCorsFilter creates a new CorsFilter
func (*CorsFilter) HandleActualRequest ¶
func (cf *CorsFilter) HandleActualRequest(w http.ResponseWriter, r *http.Request)
HandleActualRequest handles the actual request
func (*CorsFilter) HandleCors ¶
func (cf *CorsFilter) HandleCors(next http.Handler) http.Handler
CorsFilter handles the CORS headers
func (*CorsFilter) SetAllowCredentials ¶
func (cf *CorsFilter) SetAllowCredentials(allow bool)
SetAllowCredentials sets the allow credentials
func (*CorsFilter) SetAllowPvtNetwork ¶
func (cf *CorsFilter) SetAllowPvtNetwork(allow bool)
SetAllowPvtNetwork sets the allow private network
func (*CorsFilter) SetAllowedHeaders ¶
func (cf *CorsFilter) SetAllowedHeaders(headers ...string)
SetAllowedHeaders sets the allowed headers
func (*CorsFilter) SetAllowedMethods ¶
func (cf *CorsFilter) SetAllowedMethods(methods ...string)
SetAllowedMethods sets the allowed methods
func (*CorsFilter) SetAllowedOrigins ¶
func (cf *CorsFilter) SetAllowedOrigins(origins ...string)
SetAllowedOrigins sets the allowed origins
func (*CorsFilter) SetExposeHeaders ¶
func (cf *CorsFilter) SetExposeHeaders(headers ...string)
SetExposeHeaders sets the headers to expose
func (*CorsFilter) SetMaxAge ¶
func (cf *CorsFilter) SetMaxAge(maxAge int)
SetMaxAge sets the max age
func (*CorsFilter) SetPreFlightPassThrough ¶
func (cf *CorsFilter) SetPreFlightPassThrough(passThrough bool)
SetPreFlightPassThrough sets the preflight pass through
func (*CorsFilter) SetResponseStatus ¶
func (cf *CorsFilter) SetResponseStatus(status int)
SetResponseStatus sets the response status
type CorsOptions ¶
type CorsOptions struct { AllowCredentials bool `json:"allowCredentials" yaml:"allowCredentials"` AllowedHeaders []string `json:"allowedHeaders" yaml:"allowedHeaders"` AllowedMethods []string `json:"allowedMethods" yaml:"allowedMethods"` AllowedOrigins []string `json:"allowedOrigins" yaml:"allowedOrigins"` ExposeHeaders []string `json:"exposeHeaders" yaml:"exposeHeaders"` MaxAge int `json:"maxAge" yaml:"maxAge"` ResponseStatus int `json:"responseStatus" yaml:"responseStatus"` PreFlightPassThrough bool `json:"preFlightPassThrough" yaml:"preFlightPassThrough"` AllowPvtNetwork bool `json:"allowPvtNetwork" yaml:"allowPvtNetwork"` }
CorsOptions represents the options for the CORS filter
func (*CorsOptions) NewFilter ¶
func (co *CorsOptions) NewFilter() *CorsFilter
Click to show internal directories.
Click to hide internal directories.