Documentation
¶
Overview ¶
Package cors validates web origins and wraps an HTTP handler with Cross-Origin Resource Sharing headers for the self-hosted online services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateOrigins ¶
ValidateOrigins checks that every entry in origins is a unique web origin as a browser sends it: an http or https scheme and a host, with no path, query, fragment, user or wildcard.
Types ¶
type Policy ¶
type Policy struct {
// Origins are the web origins (such as "https://play.example.com") allowed to call the handler from a browser. When empty, preflight requests are refused and no Access-Control-Allow-Origin header is sent.
Origins []string
// Methods are the HTTP methods advertised in Access-Control-Allow-Methods on preflight responses.
Methods []string
// Headers are the request headers advertised in Access-Control-Allow-Headers on preflight responses.
Headers []string
// ExposeHeaders are the response headers advertised in Access-Control-Expose-Headers on responses to allowed origins.
ExposeHeaders []string
}
Policy configures CORS handling for an HTTP handler.