middleware

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

internal/api/middleware/auth.go

internal/api/middleware/authorization.go

internal/api/middleware/metrics.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminOnly

func AdminOnly() gin.HandlerFunc

func AuthMiddleware

func AuthMiddleware() gin.HandlerFunc

func AuthorizeRole

func AuthorizeRole(allowedRoles ...string) gin.HandlerFunc

func CORSMiddleware

func CORSMiddleware(cfg config.Config) gin.HandlerFunc

CORSMiddleware applies dynamic CORS settings based on config

func MetricsMiddleware

func MetricsMiddleware() gin.HandlerFunc

func RateLimit

func RateLimit(counter ratelimit.Counter, name string, limit int, window time.Duration) gin.HandlerFunc

RateLimit allows at most limit requests per client IP and window for the routes it is attached to; name separates independent budgets. A limit of 0 disables it. Counters are shared across replicas when backed by Redis.

The client IP comes from gin's ClientIP, which only trusts forwarding headers from configured trusted proxies (see trusted_proxies).

func ResponseWrapper

func ResponseWrapper() gin.HandlerFunc

func TooManyRequests

func TooManyRequests(c *gin.Context, retryAfter time.Duration, message string)

TooManyRequests aborts with 429, a Retry-After header and the standard error envelope.

Types

This section is empty.

Jump to

Keyboard shortcuts

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