Documentation ¶
Overview ¶
Package cors does cors stuff
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultConfig = Config{ Skipper: middleware.DefaultSkipper, Prefixes: nil, }
DefaultConfig creates a default config
View Source
var DefaultSchemas = []string{
"http://",
"https://",
}
DefaultSchemas is a list of default allowed schemas for CORS origins
Functions ¶
func New ¶
func New(allowedOrigins []string) echo.MiddlewareFunc
New creates a new middleware function with the default config
func NewWithConfig ¶
func NewWithConfig(config Config) (echo.MiddlewareFunc, error)
NewWithConfig creates a new middleware function with the provided config
Types ¶
type Config ¶
type Config struct { // Enable or disable the CORS middleware Enabled bool `json:"enabled" koanf:"enabled" default:"true"` Skipper middleware.Skipper `json:"-" koanf:"-"` // Prefixes is a map of prefixes to allowed origins Prefixes map[string][]string `json:"prefixes" koanf:"prefixes"` // AllowOrigins is a list of allowed origins AllowOrigins []string `json:"allowOrigins" koanf:"allowOrigins"` // CookieInsecure sets the cookie to be insecure CookieInsecure bool `json:"cookieInsecure" koanf:"cookieInsecure"` }
Config holds the cors configuration settings
type ValidationError ¶
ValidationError is returned when the origins do not pass validation
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error returns the ValidationError in string format
Click to show internal directories.
Click to hide internal directories.