middleware

package
v0.0.0-...-378fd14 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentEncoding

func ContentEncoding[R DispatchEncoder](withProviders ...ContentEncoder) dispatch.Middleware[R]

func Errors

func Errors[R dispatch.RequestAdapter, E ~int]() errorHandler[R, E]

Factory function to create an error handler middleware

func HostnameEnforcement

func HostnameEnforcement[R dispatch.RequestAdapter](hostname string) dispatch.Middleware[R]

func Logger

func Logger[R DispatchLogger](format string, logger io.Writer) dispatch.Middleware[R]

func SessionMW

func SessionMW[S Session, R SessionAdapter[S]](store SessionStore[S], log io.Writer) dispatch.Middleware[R]

Types

type ContentEncoder

type ContentEncoder interface {
	Name() string
	Create(io.Writer) io.Writer
	Pool() *sync.Pool
}

type DefaultSessionStore

type DefaultSessionStore[S Session] struct {
	CookieName string

	sync.Map
	// contains filtered or unexported fields
}

func NewDefaultSessionStore

func NewDefaultSessionStore[S Session](cookieName string) *DefaultSessionStore[S]

func (*DefaultSessionStore[S]) Load

func (store *DefaultSessionStore[S]) Load(r *http.Request) S

func (*DefaultSessionStore[S]) StoreSession

func (store *DefaultSessionStore[S]) StoreSession(s S) error

func (*DefaultSessionStore[S]) WriteCookie

func (store *DefaultSessionStore[S]) WriteCookie(w http.ResponseWriter, s S)

type DispatchEncoder

type DispatchEncoder interface {
	dispatch.RequestAdapter
	Encoder() *EncodingData
}

type DispatchLogger

type DispatchLogger interface {
	dispatch.RequestAdapter
	Log() *LoggerData
}

type EncodingData

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

type ErrorHandler

type ErrorHandler[R dispatch.RequestAdapter] interface {
	Self() func(ctn *dispatch.ContentTypeNegotiator, logger io.Writer) dispatch.Middleware[R]
	// contains filtered or unexported methods
}

type LoggerData

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

type RateLimiter

type RateLimiter[R dispatch.RequestAdapter] struct {
	// contains filtered or unexported fields
}

func NewRateLimiter

func NewRateLimiter[R dispatch.RequestAdapter](
	cacheProvider cache.Cache,
	idFunc func(R) string,
	maxVisits int,
	perDuration time.Duration,
	log io.Writer,
) *RateLimiter[R]

func (*RateLimiter[R]) Enter

func (rl *RateLimiter[R]) Enter(w http.ResponseWriter, r R) (http.ResponseWriter, R, bool)

func (*RateLimiter[R]) Exit

func (rl *RateLimiter[R]) Exit(w http.ResponseWriter, r R)

type RogueStopper

type RogueStopper[R dispatch.RequestAdapter] struct {
	// contains filtered or unexported fields
}

func NewRogueStopper

func NewRogueStopper[R dispatch.RequestAdapter](
	cacheProvider cache.Cache,
	idFunc func(R) string,
	maxBadRequests int,
	perDuration time.Duration,
	timeout time.Duration,
	log io.Writer,
) *RogueStopper[R]

func (*RogueStopper[R]) Enter

func (bac *RogueStopper[R]) Enter(w http.ResponseWriter, r R) (http.ResponseWriter, R, bool)

func (*RogueStopper[R]) Exit

func (bac *RogueStopper[R]) Exit(w http.ResponseWriter, r R)

type Session

type Session interface {
	Id() string
}

type SessionAdapter

type SessionAdapter[S Session] interface {
	dispatch.RequestAdapter
	GetSession() S
	SetSession(S)
}

type SessionStore

type SessionStore[S Session] interface {
	Load(*http.Request) S
	StoreSession(S) error
	WriteCookie(http.ResponseWriter, S)
}

type WriteFlusher

type WriteFlusher interface {
	io.Writer
	Flush() error
}

Jump to

Keyboard shortcuts

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