Skip to main content

build_http_client

Function build_http_client 

Source
pub fn build_http_client() -> ClientWithMiddleware
Expand description

Build a configured HTTP client with smart retry middleware

The client includes:

  • Smart Retry Logic: Respects server Retry-After headers for 429 responses
  • Exponential Backoff: For server errors (5xx) and network issues
  • Timeout: 10 second request timeout
  • Max Retries: 5 attempts

ยงExample

use elo::http::build_http_client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = build_http_client();
    let response = client.get("https://api.example.com/status").send().await?;
    Ok(())
}