Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
func Default() looli.HandlerFunc
Default return cors middleware with default options being all origins accepted, AllowMethods default is []string{"GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"}.
func New ¶
func New(option Options) looli.HandlerFunc
Types ¶
type Options ¶
type Options struct { // AllowedOrigins 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. AllowOrigins []string // AllowOriginFunc is a custom function to validate the origin. It take the origin // as argument and returns true if allowed or false otherwise. If this option is // set, the content of AllowedOrigins is ignored. AllowOriginsFunc func(string) bool // specifies the method or methods allowed when accessing the resource. This is used in response // to a preflight request, default is []string{"GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"}. AllowMethods []string // header is used in response to a preflight request to indicate which HTTP headers can be used when // making the actual request AllowHeaders []string // The Access-Control-Allow-Credentials header 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. Note that // simple GET requests are not preflighted, and so if a request is made for a resource with credentials, // if this header is not returned with the resource, the response is ignored by the browser and not // returned to web content. AllowCredentials bool // ExposeHeaders header lets a server whitelist headers that browsers are allowed to access. // For example: Access-Control-Expose-Headers: "X-My-Custom-Header, X-Another-Custom-Header" // This allows the X-My-Custom-Header and X-Another-Custom-Header headers to be exposed to the browser. ExposeHeaders []string // MaxAge indicates how long the results of a preflight request can be cached. MaxAge time.Duration }
Click to show internal directories.
Click to hide internal directories.