cors

package
v0.0.0-...-8aeb8a1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//AppTopLevelDomainTemplate matches when host top level domain == origin top level domain (abc.com == abc.com)
	AppTopLevelDomainTemplate = "{{APP_TLD}}"
	//AppSecondLevelDomainTemplate matches any origin domain if host top level domain == origin top level domain (app.abc.com == noapp.abc.com)
	AppSecondLevelDomainTemplate = "*.{{APP_TLD}}"
)

Variables

This section is empty.

Functions

func ExtractTopLevelAndDomain

func ExtractTopLevelAndDomain(adr string) (string, string)

ExtractTopLevelAndDomain returns top level domain and domain e.g. abc.efg.com returns "efg.com", "abc"

Types

type AppDomainRule

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

AppDomainRule replaced AppTopLevelDomainTemplate with input HOST header and uses PrefixSuffixRule

func (*AppDomainRule) IsAllowed

func (adr *AppDomainRule) IsAllowed(host, reqOrigin string) bool

IsAllowed returns true if reqOrigin matches the rule

type PrefixSuffixRule

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

PrefixSuffixRule checks domain by prefix abc* and suffix: *.abc.com

func (*PrefixSuffixRule) IsAllowed

func (psr *PrefixSuffixRule) IsAllowed(host, reqOrigin string) bool

IsAllowed returns true if reqOrigin matches the rule

type Rule

type Rule interface {
	IsAllowed(host, origin string) bool
}

Rule is a CORS rule

func NewPrefixSuffixRule

func NewPrefixSuffixRule(expression string) Rule

NewPrefixSuffixRule returns PrefixSuffixRule

func NewRule

func NewRule(expression string) Rule

NewRule returns Rule based on expression

Jump to

Keyboard shortcuts

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