Skip to main content

rate_limit

Function rate_limit 

Source
pub async fn rate_limit(
    __arg0: State<Arc<RateLimiterState>>,
    request: Request,
    next: Next,
) -> Result<Response, StatusCode>
Expand description

Axum middleware that rejects requests with 429 when the token bucket is exhausted.

§Errors

Returns StatusCode::TOO_MANY_REQUESTS if the token bucket has no remaining capacity.