middleware

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowedHosts

func AllowedHosts(next http.Handler) http.Handler

func CacheControl added in v0.1.30

func CacheControl(duration time.Duration) func(next http.Handler) http.Handler

func GenerateRequestID

func GenerateRequestID() string

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID extracts the request ID from context

func GetUserFromContext

func GetUserFromContext(ctx context.Context) *models.User

func Logger

func Logger(baseLogger *zerolog.Logger) func(next http.Handler) http.Handler

Logger logs requests and injects a request-scoped logger with a request ID into the context.

func SecurityHeaders added in v0.1.30

func SecurityHeaders(next http.Handler) http.Handler

SecurityHeaders adds standard security headers to every response

func ValidateApiKey

func ValidateApiKey(store db.DB) func(next http.Handler) http.Handler

func ValidateSession

func ValidateSession(store db.DB) func(next http.Handler) http.Handler

func WithRequestID

func WithRequestID(next http.Handler) http.Handler

Types

type MiddlwareContextKey

type MiddlwareContextKey string
const (
	UserContextKey MiddlwareContextKey = "user"
)

type RequestIDHook

type RequestIDHook struct{}

func (RequestIDHook) Run

func (h RequestIDHook) Run(e *zerolog.Event, level zerolog.Level, msg string)

Jump to

Keyboard shortcuts

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