middleware

package
v0.0.0-...-bc54189 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const RequestBodyContextKey requestBodyKey = "request_body"

Variables

This section is empty.

Functions

func Auth

func Auth(store authstore.Store, cfg config.AuthConfig) func(http.Handler) http.Handler

Auth validates API keys from the X-API-Key header

func Cache

func Cache(
	redisClient cacheReader,
	hasher *internalCache.SemanticHasher,
	ttlMgr cacheWriter,
	cfg config.CacheConfig,
) func(http.Handler) http.Handler

Cache middleware checks Redis for cached responses and stores new ones. Cache keys are namespaced by API key so tenants never share cached data.

func DashboardStats

func DashboardStats(store *dashboard.Store) func(http.Handler) http.Handler

DashboardStats records per-key stats for the dashboard views.

func GetAPIKey

func GetAPIKey(ctx context.Context) string

func GetOwner

func GetOwner(ctx context.Context) string

func GetRole

func GetRole(ctx context.Context) string

func GetTier

func GetTier(ctx context.Context) string

func Logging

func Logging() func(http.Handler) http.Handler

Logging middleware provides structured request logging

func Metrics

func Metrics() func(http.Handler) http.Handler

Metrics middleware records Prometheus metrics for each request

func RateLimit

func RateLimit(bucket *ratelimit.TokenBucket, cfg config.RateLimitConfig) func(http.Handler) http.Handler

RateLimit middleware applies per-API-key token bucket rate limiting

func Recovery

func Recovery() func(http.Handler) http.Handler

Recovery middleware recovers from panics and returns a well-formed JSON 500

func RequireRole

func RequireRole(roles ...string) func(http.Handler) http.Handler

RequireRole enforces that the caller has one of the allowed roles.

Types

This section is empty.

Jump to

Keyboard shortcuts

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