Crate reqwest_ratelimit
source ·Expand description
Middleware to rate-limit requests built on reqwest_middleware
.
You’re exected to provide your own RateLimiter
implementation.
§Example
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();
}
Structs§
- Request rate-limiting middleware.
Traits§
- Request rate limiter.
Functions§
- Creates a new
Middleware
rate-limiting all requests using the providedRateLimiter
.