surf-governor

Crates.iosurf-governor
lib.rssurf-governor
version0.2.0
sourcesrc
created_at2022-05-22 22:12:49.807533
updated_at2023-07-14 21:33:08.90036
descriptionA rate-limiting middleware for surf
homepage
repositoryhttps://github.com/06chaynes/surf-governor.git
max_upload_size
id591467
size26,814
Christian Haynes (06chaynes)

documentation

README

surf-governor

A rate-limiting middleware for surf

Install

With cargo add installed :

cargo add surf-governor

Documentation

Example

use surf_governor::GovernorMiddleware;
use surf::{Client, Request, http::Method};
use url::Url;

#[async_std::main]
async fn main() -> surf::Result<()> {
    let req = Request::new(Method::Get, Url::parse("https://example.api")?);
    let client = Client::new().with(GovernorMiddleware::per_second(1)?);
    let res = client.send(req).await?;
    Ok(())
}
Commit count: 10

cargo fmt