Skip to main content

rate_limit

Function rate_limit 

Source
pub async fn rate_limit(req: Request, next: Next) -> Response
Expand description

Axum middleware that enforces the per-token rate limit.

Reads AuthContext from request extensions (inserted by crate::middleware::bearer_auth) and consults the RateLimiter supplied via an axum::Extension. On bucket-empty, returns 429 Too Many Requests with a Retry-After header.

When no RateLimiter is in the extensions the middleware is a pass-through (the operator did not configure rate limiting).