CORS

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidationMap map[string]ValidationFunc

Functions

func SetValidationFunction added in v0.7.5

func SetValidationFunction(name string, fx ValidationFunc)

func ValidateWithRedisPrefix added in v0.7.5

func ValidateWithRedisPrefix(req *http.Request, rw *goftlmux.MidBuffer, hdlr *CORSType) bool

--------------------------------------------------------------------------------------------------------------------------

Types

type CORSType

type CORSType struct {
	Next               http.Handler
	Paths              []string `gfType:"string,filepath" gfRequired:"true"`
	CookiePolyfilPaths []string `gfType:"string,filepath" gfDefault:"/api/cors-session-cookie-polyfil.js"`
	AllowedOrigins     []string `gfDefault:""` // Array of RE to match
	AllowedMethods     []string `gfDefault:""`
	ExposedHeaders     []string `gfDefault:""`
	AllowCredentials   bool     `gfDefault:"false"`
	AllowOriginFunc    string   `gfDefault:""`
	AllowedHeaders     []string `gfDefault:""`
	MaxAge             int      `gfDefault:"86400"`
	GetOriginURI       string   `gfDefault:"/api/cors/GetOrigin"`
	OptionPassthrough  bool     `gfDefault:"false"`
	LineNo             int      `gfDefault:"1"`

	Debug01     bool   `gfDefault:"true"`
	RedisPrefix string `gfDefault:""`
	// contains filtered or unexported fields
}

allowOriginFunc func(origin string) bool // Optional origin validation function

func NewCORSServer

func NewCORSServer(n http.Handler, p []string, ml int) *CORSType

func (*CORSType) InitializeWithConfigData

func (hdlr *CORSType) InitializeWithConfigData(next http.Handler, gCfg *cfg.ServerGlobalConfigType, serverName string, pNo, callNo int) (err error)

func (*CORSType) PreValidate

func (hdlr *CORSType) PreValidate(gCfg *cfg.ServerGlobalConfigType, cfgData map[string]interface{}, serverName string, pNo, callNo int) (err error)

func (*CORSType) RedisGetValidOrigin

func (hdlr *CORSType) RedisGetValidOrigin(key string) (val string, err error)

func (*CORSType) ServeHTTP

func (hdlr *CORSType) ServeHTTP(www http.ResponseWriter, req *http.Request)

type RedisCORSType added in v0.7.6

type RedisCORSType struct {
	Valid        string            `json:"Valid"`
	AddToRequest map[string]string `json:"AddToRequest"`
}

type ValidationFunc

type ValidationFunc func(req *http.Request, rw *goftlmux.MidBuffer, hdlr *CORSType) bool

Jump to

Keyboard shortcuts

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