Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultSchemas = []string{"http://", "https://"} ExtensionSchemas = []string{"chrome-extension://", "safari-extension://", "moz-extension://", "ms-browser-extension://"} FileSchemas = []string{"file://"} WebSocketSchemas = []string{"ws://", "wss://"} )
Functions ¶
Types ¶
type Config ¶
type Config struct { AbortOnError bool // AllowOrigins is a list of origins a cross-domain request can be executed from. // If the special "*" value is present in the list, all origins will be allowed. // An origin may contain a wildcard (*) to replace 0 or more characters // (i.e.: http://*.domain.com). Usage of wildcards implies a small performance penalty. // Only one wildcard can be used per origin. // Default "*" (all origins allowed) AllowOrigins []string // AllowOriginFunc is a custom function to validate the origin. // If this option is set, the content of AllowOrigins is ignored. AllowOriginFunc func(origin string) bool // AllowRequestOriginFunc is a custom function to validate the origin. // If this option is set, AllowOrigins and AllowOriginFunc are ignored. AllowRequestOriginFunc func(r *http.Request, origin string) bool // AllowMethods is a list of methods the client is allowed to use with // cross-domain requests. Default value is simple methods (HEAD, GET and POST). AllowMethods []string // AllowHeaders is list of non-simple headers the client is allowed to use with // cross-domain requests. // If the special "*" value is present in the list, all headers will be allowed. // Default value is [] but headers.HeaderOrigin is always appended to the list. AllowHeaders []string // ExposeHeaders indicates which headers are safe to expose to the API of a Default // API specification ExposeHeaders []string // AllowCredentials indicates whether the request can include user credentials like // cookies, HTTP authentication or client side SSL certificates. AllowCredentials bool // MaxAge indicates how long (in seconds) the results of a preflight request can be cached MaxAge time.Duration // OptionsPassthrough instructs preflight to let other potential next handlers to // process the OPTIONS method. Turn this on if your application handles OPTIONS. OptionsPassthrough bool // Provides a status code to use for successful OPTIONS requests. // Default value is http.StatusNoContent (204). OptionsSuccessStatus int // AllowWildcard allows adding origins like http://some-domain/*, https://api.* or http://some.*.subdomain.com AllowWildcard bool // AllowBrowserExtensions allows usage of popular browser extensions schemas AllowBrowserExtensions bool // AllowWebSockets allows usage of WebSocket protocol AllowWebSockets bool // AllowFiles allows usage of file:// schema (dangerous!) use it only when you 100% sure it's needed AllowFiles bool // Debug flag adds additional output to Debug server side Default issues Debug bool }
Config is a configuration container to set up the Default httpmiddleware.
func DefaultConfig ¶
func DefaultConfig() *Config
func (*Config) AddAllowHeaders ¶
func (*Config) AddAllowMethods ¶
func (*Config) AddExposeHeaders ¶
Click to show internal directories.
Click to hide internal directories.