middleware

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate added in v0.1.6

func Authenticate(store db.UserStore, mode AuthMode) func(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 WithRequestID

func WithRequestID(next http.Handler) http.Handler

Types

type AuthMode added in v0.1.6

type AuthMode int
const (
	AuthModeSessionCookie AuthMode = iota
	AuthModeAPIKey
	AuthModeSessionOrAPIKey
	AuthModeLoginGate
)

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