mod_cors

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModCors                             = "mod_cors"
	HeaderAccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	HeaderAccessControlAllowMethods     = "Access-Control-Allow-Methods"
	HeaderAccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	HeaderAccessControlMaxAge           = "Access-Control-Max-Age"
	HeaderAccessControlExposeHeaders    = "Access-Control-Expose-Headers"
	HeaderAccessControlRequestMethod    = "Access-Control-Request-Method"
	HeaderOrigin                        = "Origin"
	HeaderVary                          = "Vary"
)

Variables

This section is empty.

Functions

func CorsRuleCheck

func CorsRuleCheck(corsRuleFile *CorsRuleFile) error

Types

type ConfModCors

type ConfModCors struct {
	Basic struct {
		DataPath string // path of rule data
	}

	Log struct {
		OpenDebug bool
	}
}

func ConfLoad

func ConfLoad(filePath string, confRoot string) (*ConfModCors, error)

func (*ConfModCors) Check

func (cfg *ConfModCors) Check(confRoot string) error

type CorsRule

type CorsRule struct {
	Cond                          condition.Condition
	AccessControlAllowOriginMap   map[string]bool
	AccessControlAllowCredentials bool
	AccessControlExposeHeaders    []string
	AccessControlAllowMethods     []string
	AccessControlAllowHeaders     []string
	AccessControlMaxAge           *int
}

type CorsRuleConf

type CorsRuleConf struct {
	Version string
	Config  ProductRuleList // product -> rule list
}

func CorsRuleFileLoad

func CorsRuleFileLoad(filename string) (*CorsRuleConf, error)

type CorsRuleFile

type CorsRuleFile struct {
	Version string
	Config  ProductRuleRawList // product -> raw rule list
}

type CorsRuleList

type CorsRuleList []CorsRule

type CorsRuleRaw

type CorsRuleRaw struct {
	Cond string // condition

	// AccessControlAllowOrigins specifies either a single origin, which tells browsers to
	// allow that origin to access the resource; or else — for requests without credentials —
	// the "*" wildcard, to tell browsers to allow any origin to access the resource
	AccessControlAllowOrigins []string

	// AccessControlAllowCredentials Indicates whether or not the response to the request can be exposed
	AccessControlAllowCredentials bool

	// AccessControlExposeHeaders lets a server whitelist headers that browsers are allowed to access.
	AccessControlExposeHeaders []string

	// AccessControlAllowMethods specifies the method or methods allowed when accessing the resource.
	// This is used in response to a preflight request.
	AccessControlAllowMethods []string

	// AccessControlAllowHeaders indicates which HTTP headers can be used when making the actual request.
	// This is used in response to a preflight request.
	AccessControlAllowHeaders []string

	// AccessControlMaxAge indicates how long the results of a preflight request can be cached.
	// This is used in response to a preflight request.
	AccessControlMaxAge *int
}

type CorsRuleTable

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

func NewCorsRuleTable

func NewCorsRuleTable() *CorsRuleTable

func (*CorsRuleTable) Search

func (t *CorsRuleTable) Search(product string) (CorsRuleList, bool)

func (*CorsRuleTable) Update

func (t *CorsRuleTable) Update(ruleConf *CorsRuleConf)

type ModuleCors

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

func NewModuleCors

func NewModuleCors() *ModuleCors

func (*ModuleCors) Init

func (*ModuleCors) Name

func (m *ModuleCors) Name() string

type ModuleCorsState

type ModuleCorsState struct {
	ReqCorsRuleHit       *metrics.Counter
	ReqPreFlightHit      *metrics.Counter
	ReqAllowOriginHit    *metrics.Counter
	ReqNotAllowOriginHit *metrics.Counter
}

type ProductRuleList

type ProductRuleList map[string]CorsRuleList // product => list of cors rule list

type ProductRuleRawList

type ProductRuleRawList map[string]RuleRawList // product => raw rule list

type RuleRawList

type RuleRawList []CorsRuleRaw

Jump to

Keyboard shortcuts

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