tide-governor

Crates.iotide-governor
lib.rstide-governor
version1.0.3
sourcesrc
created_at2020-12-24 18:36:35.055301
updated_at2021-09-16 00:06:18.915569
descriptionA rate-limiting middleware for tide
homepagehttps://github.com/ohmree/tide-governor
repositoryhttps://github.com/ohmree/tide-governor
max_upload_size
id326962
size9,492
(ohmree)

documentation

https://docs.rs/tide-governor

README

tide-governor

A tide middleware that provides rate-limiting functionality backed by governor

Example

use tide_governor::GovernorMiddleware;
use std::env;

#[async_std::main]
async fn main() -> tide::Result<()> {
    let mut app = tide::new();
    app.at("/")
        .with(GovernorMiddleware::per_minute(4)?)
        .get(|_| async move { todo!() });
    app.at("/foo/:bar")
        .with(GovernorMiddleware::per_hour(360)?)
        .put(|_| async move { todo!() });

    app.listen(format!("http://localhost:{}", env::var("PORT")?))
        .await?;
    Ok(())
}
Commit count: 28

cargo fmt