cors

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

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() 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

func Validate

func Validate(origins []string) error

Validate checks a list of origins to see if they comply with the allowed origins

Types

type Config

type Config struct {
	// Skipper defines a function to skip middleware.
	Skipper  middleware.Skipper
	Prefixes map[string][]string
}

Config holds the cors configuration settings

type ValidationError

type ValidationError struct {
	Validation string
	Allowed    string
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL