write_rate_limit_error

Function write_rate_limit_error 

Source
pub async fn write_rate_limit_error(
    session: &mut Session,
    status: u16,
    body: &str,
    limit: u32,
    remaining: u32,
    reset_at: u64,
    retry_after: u64,
) -> Result<(), Box<Error>>
Expand description

Write a rate limit error response with standard rate limit headers

Includes the following headers:

  • X-RateLimit-Limit: Maximum requests per window
  • X-RateLimit-Remaining: Remaining requests in current window
  • X-RateLimit-Reset: Unix timestamp when the window resets
  • Retry-After: Seconds until the client should retry (for 429 responses)

ยงArguments

  • session - The Pingora session to write to
  • status - HTTP status code (typically 429)
  • body - Response body as string
  • limit - Maximum requests allowed per window
  • remaining - Remaining requests in current window
  • reset_at - Unix timestamp when the window resets
  • retry_after - Seconds until client should retry