middleware

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicSecurityHeaderMiddleware

func BasicSecurityHeaderMiddleware() mux.MiddlewareFunc

func CacheControlMiddleware

func CacheControlMiddleware(globPatterns []string, directive *CacheControlDirective) mux.MiddlewareFunc

CacheControlMiddleware is the middleware function to be provided as a parameter to mux.Handler()

Types

type CacheControlDirective

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

CacheControlDirective is a data structure that represents the entry for Cache-Control rules

func NewCacheControlDirective

func NewCacheControlDirective() *CacheControlDirective

NewCacheControlDirective returns creates a new instance of CacheControlDirective and returns its pointer

func (*CacheControlDirective) Immutable

func (*CacheControlDirective) MaxAge

func (*CacheControlDirective) MaxStale

func (*CacheControlDirective) MinFresh

func (*CacheControlDirective) MustRevalidate

func (c *CacheControlDirective) MustRevalidate() *CacheControlDirective

func (*CacheControlDirective) NoCache

func (*CacheControlDirective) NoStore

func (*CacheControlDirective) NoTransform

func (c *CacheControlDirective) NoTransform() *CacheControlDirective

func (*CacheControlDirective) OnlyIfCached

func (c *CacheControlDirective) OnlyIfCached() *CacheControlDirective

func (*CacheControlDirective) Private

func (*CacheControlDirective) ProxyRevalidate

func (c *CacheControlDirective) ProxyRevalidate() *CacheControlDirective

func (*CacheControlDirective) Public

func (*CacheControlDirective) SharedMaxAge

func (*CacheControlDirective) String

func (c *CacheControlDirective) String() string

type CacheControlRulePair

type CacheControlRulePair struct {
	GlobPattern         string
	CacheControlRule    string
	CompiledGlobPattern glob.Glob
}

CacheControlRulePair is a container that lumps together the glob pattern, cache control rule that should be applied to for the matching pattern and the compiled glob pattern for use in runtime. see https://github.com/gobwas/glob for detailed examples of glob patterns.

func NewCacheControlRulePair

func NewCacheControlRulePair(globPattern string, cacheControlRule string) (CacheControlRulePair, error)

NewCacheControlRulePair returns a new CacheControlRulePair with the provided text glob pattern and its compiled counterpart and the cache control rule.

type Middleware

type Middleware interface {
	//Intercept(h http.Handler) http.Handler
	Interceptor() mux.MiddlewareFunc
	Name() string
}

type MiddlewareManager

type MiddlewareManager interface {
	SetGlobalMiddleware(middleware []mux.MiddlewareFunc) error
	SetNewMiddleware(route *mux.Route, middleware []mux.MiddlewareFunc) error
	RemoveMiddleware(route *mux.Route) error
	GetRouteByUriAndMethod(uri, method string) (*mux.Route, error)
	GetRouteByUri(uri string) (*mux.Route, error)
	GetStaticRoute(prefix string) (*mux.Route, error)
}

func NewMiddlewareManager

func NewMiddlewareManager(endpointHandlerMapPtr *map[string]http.HandlerFunc, router *mux.Router, logger *slog.Logger) MiddlewareManager

NewMiddlewareManager sets up a new middleware manager singleton instance

Jump to

Keyboard shortcuts

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