Skip to main content

rate_limit_layer

Function rate_limit_layer 

Source
pub async fn rate_limit_layer(
    __arg0: State<RateLimiter>,
    req: Request<Body>,
    next: Next,
) -> Response
Expand description

Stackable middleware function: fixed-window rate limit on /v1/* per client IP (taken from the ConnectInfo extension, which axum::serve provides when the router is served via into_make_service_with_connect_info). Requests without connect info (unit tests, or any future non-TCP transport such as a Unix socket or a Windows named pipe) are passed through — per-IP limiting is only enforceable when the peer address is known.