middleware

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FormKeyAppID is a form key to keep application ID.
	FormKeyAppID = "appId"
)

Variables

This section is empty.

Functions

func AppFromContext

func AppFromContext(ctx context.Context) model.AppData

AppFromContext returns app data from request conntext.

func AppID

func AppID(
	logger *slog.Logger,
	errorPath string,
	appStorage model.AppStorage,
) negroni.HandlerFunc

AppID gets app id from the request body.

func HTTPLogger added in v2.10.0

func HTTPLogger(
	component string,
	format string,
	logParams model.LoggerParams,
	httpDetailing model.HTTPDetailing,
	excludeAuth bool,
	exclude ...string,
) func(http.Handler) http.Handler

func NegroniHTTPLogger added in v2.10.0

func NegroniHTTPLogger(
	component string,
	format string,
	logParams model.LoggerParams,
	httpDetailing model.HTTPDetailing,
	excludeAuth bool,
	exclude ...string,
) negroni.Handler

func NewCacheDisable added in v2.2.19

func NewCacheDisable() negroni.HandlerFunc

func NewOriginCheckerWithFunc

func NewOriginCheckerWithFunc(f model.OriginCheckFunc) model.OriginChecker

NewOriginChecker creates new instance of an OriginChecker.

func RemoveTrailingSlash added in v2.10.0

func RemoveTrailingSlash() negroni.HandlerFunc

Types

type AppOriginChecker

type AppOriginChecker struct {
	OriginChecker
	// contains filtered or unexported fields
}

func NewAppOriginChecker

func NewAppOriginChecker(appstorage model.AppStorage) (*AppOriginChecker, error)

NewOriginChecker creates new instance of an OriginChecker.

func (*AppOriginChecker) Update

func (aoc *AppOriginChecker) Update() error

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) AddCheck

func (os *OriginChecker) AddCheck(f model.OriginCheckFunc)

With adds AllowOriginRequestFunc to list of checks.

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) Update

func (os *OriginChecker) Update() error

Jump to

Keyboard shortcuts

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