httpmiddleware

package
v0.0.0-...-4be01c1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout   = time.Second * 30
	MaxCustomTimeout = time.Minute * 1
)
View Source
const LoggerKey string = "LoggerKey"

Variables

View Source
var (
	ErrInvalidKeepAliveHeader = errors.New("Could not parse Keep-Alive Header")
)

Functions

func BlockQuery

func BlockQuery() int

func GetIntervalFromContext

func GetIntervalFromContext(r *http.Request) timeutil.TimeInterval

func GetSession

func GetSession(ctx context.Context) *sessions.Session

func LoggerWithHTTPContext

func LoggerWithHTTPContext(requestId string) zerolog.Logger

Logger returns a logger with http context

Types

type Chain

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

func New

func New(middleware ...Middleware) Chain

func WithDefaultStack

func WithDefaultStack(auth *auth.Authenticator, middleware ...Middleware) Chain

func WithDefaultStackWithoutAuth

func WithDefaultStackWithoutAuth(middleware ...Middleware) Chain

func (Chain) WithEndpoint

func (c Chain) WithEndpoint(endpoint CustomHTTPHandlerInterface) http.Handler

type CustomHTTPHandler

type CustomHTTPHandler func(w http.ResponseWriter, r *http.Request) error

func (CustomHTTPHandler) ServeHTTP

type CustomHTTPHandlerInterface

type CustomHTTPHandlerInterface interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request) error
}

type Interval

type Interval string

type Middleware

type Middleware func(CustomHTTPHandler) CustomHTTPHandler

func RequestWithInterval

func RequestWithInterval(timezone *time.Location) Middleware

func RequestWithRateLimit

func RequestWithRateLimit(timeFrame time.Duration, numberOfTries int64, isBehindAReverseProxy bool, action RestrictAction) Middleware

func RequestWithSession

func RequestWithSession(authenticator *auth.Authenticator) Middleware

func RequestWithTimeout

func RequestWithTimeout(defaultTimeout time.Duration) Middleware

func RequireAuthenticationOnlyAfterSystemHasAnyUser

func RequireAuthenticationOnlyAfterSystemHasAnyUser(auth *httpauth.Authenticator) Middleware

RequireAuthenticationOnlyAfterSystemHasAnyUser allows something to be seen only if before the user registration ends or the user is authenticated

type RequestID

type RequestID string
const RequestIDKey RequestID = "RequestIDKey"

type RestrictAction

type RestrictAction func() int

Data structures to define rate-limiting behaviour

type SessionName

type SessionName string
const SessionKey SessionName = auth.SessionName

Jump to

Keyboard shortcuts

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