originchecker

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OriginChecker

type OriginChecker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

OriginChecker holds user's AllowOriginRequestFunc and checks dynamically added CORS origins from an all app's redirect urls.

func NewOriginChecker

func NewOriginChecker() *OriginChecker

NewOriginChecker creates new instance of an OriginChecker.

func (*OriginChecker) Add

func (os *OriginChecker) Add(origin string)

Add adds origin to the list of allowed origins.

func (*OriginChecker) AddRawURLs

func (os *OriginChecker) AddRawURLs(urls []string)

AddRawURLs parses and adds urls to the list of allowed origins.

func (*OriginChecker) CheckOrigin

func (os *OriginChecker) CheckOrigin(r *http.Request, origin string) bool

CheckOrigin is a custom func for validate origin, checking it with all AllowOriginRequestFuncs, including user's provided func.

func (*OriginChecker) Delete

func (os *OriginChecker) Delete(origin string)

Delete removes origin from the list of allowed origins.

func (*OriginChecker) DeleteAll

func (os *OriginChecker) DeleteAll()

DeleteAll removes all origins from the global origin map.

func (*OriginChecker) IsPresent

func (os *OriginChecker) IsPresent(origin string) bool

IsPresent returns true if the provided origin presented in the origins map, false otherwise.

func (*OriginChecker) With

func (os *OriginChecker) With(f func(r *http.Request, origin string) bool) *OriginChecker

With adds AllowOriginRequestFunc to list of checks.

Jump to

Keyboard shortcuts

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