Crates.io | tide-governor |
lib.rs | tide-governor |
version | 1.0.3 |
source | src |
created_at | 2020-12-24 18:36:35.055301 |
updated_at | 2021-09-16 00:06:18.915569 |
description | A rate-limiting middleware for tide |
homepage | https://github.com/ohmree/tide-governor |
repository | https://github.com/ohmree/tide-governor |
max_upload_size | |
id | 326962 |
size | 9,492 |
A tide middleware that provides rate-limiting functionality backed by governor
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(())
}