reqwest-ratelimit

Crates.ioreqwest-ratelimit
lib.rsreqwest-ratelimit
version0.2.0
sourcesrc
created_at2023-09-28 18:58:14.040272
updated_at2024-05-04 22:29:43.504107
descriptionRate-limit middleware for reqwest.
homepage
repositoryhttps://github.com/xDarksome/reqwest-ratelimit
max_upload_size
id986495
size5,151
(xDarksome)

documentation

README

reqwest-ratelimit

Rate-limit middleware implementation for reqwest-middleware.

Crates.io Docs.rs

Usage

use async_trait::async_trait;
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};

struct RateLimiter;

#[async_trait]
impl reqwest_ratelimit::RateLimiter for RateLimiter {
    async fn acquire_permit(&self) {
        // noop
    }
}

async fn run() {
    let client = ClientBuilder::new(reqwest::Client::new())
        .with(reqwest_ratelimit::all(RateLimiter))
        .build();

    client.get("https://crates.io").send().await.unwrap();
}
Commit count: 6

cargo fmt