cors

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseListenerPriority = -100
)

Variables

This section is empty.

Functions

func DefaultMiddleware

func DefaultMiddleware() httpcontract.Middleware

func Middleware

func Middleware(service *Service) httpcontract.Middleware

func RegisterResponseListener

func RegisterResponseListener(eventDispatcher eventcontract.EventDispatcher, service *Service)

func Restrictive

func Restrictive(allowedOrigins ...string) httpcontract.Middleware

Types

type Config

type Config struct {
	AllowOrigins     []string
	AllowMethods     []string
	AllowHeaders     []string
	ExposeHeaders    []string
	AllowCredentials bool
	MaxAge           int
	AllowOriginFunc  func(origin string) bool
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func DefaultService

func DefaultService() *Service

func NewService

func NewService(config Config) *Service

func RestrictiveService

func RestrictiveService(allowedOrigins []string) *Service

func (*Service) AllowCredentials

func (instance *Service) AllowCredentials() bool

func (*Service) AllowHeaders

func (instance *Service) AllowHeaders() []string

func (*Service) AllowHeadersString

func (instance *Service) AllowHeadersString() string

func (*Service) AllowMethods

func (instance *Service) AllowMethods() []string

func (*Service) AllowMethodsString

func (instance *Service) AllowMethodsString() string

func (*Service) AllowOrigins

func (instance *Service) AllowOrigins() []string

func (*Service) ApplyPreflightHeaders

func (instance *Service) ApplyPreflightHeaders(origin string, headers nethttp.Header)

func (*Service) ApplyResponseHeaders

func (instance *Service) ApplyResponseHeaders(origin string, headers nethttp.Header)

func (*Service) ExposeHeaders

func (instance *Service) ExposeHeaders() []string

func (*Service) ExposeHeadersString

func (instance *Service) ExposeHeadersString() string

func (*Service) IsPreflight

func (instance *Service) IsPreflight(request httpcontract.Request) bool

func (*Service) MaxAge

func (instance *Service) MaxAge() int

func (*Service) OriginAllowed

func (instance *Service) OriginAllowed(origin string) bool

func (*Service) RequestOrigin

func (instance *Service) RequestOrigin(request httpcontract.Request) string

Jump to

Keyboard shortcuts

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