| Crates.io | armature-ratelimit |
| lib.rs | armature-ratelimit |
| version | 0.1.2 |
| created_at | 2025-12-27 01:20:55.232319+00 |
| updated_at | 2025-12-30 22:30:09.916697+00 |
| description | Rate limiting middleware for Armature framework with multiple algorithms and storage backends |
| homepage | https://pegasusheavy.github.io/armature |
| repository | https://github.com/pegasusheavy/armature |
| max_upload_size | |
| id | 2006530 |
| size | 173,187 |
Rate limiting middleware for the Armature framework.
[dependencies]
armature-ratelimit = "0.1"
use armature_ratelimit::{RateLimiter, RateLimitConfig};
let limiter = RateLimiter::new(RateLimitConfig {
requests: 100,
window: Duration::from_secs(60),
key_extractor: |req| req.header("X-API-Key").unwrap_or("anonymous"),
});
let app = Application::new()
.with_middleware(limiter)
.get("/api/data", handler);
let limiter = RateLimiter::token_bucket(100, Duration::from_secs(1));
let limiter = RateLimiter::sliding_window(100, Duration::from_secs(60));
let limiter = RateLimiter::fixed_window(100, Duration::from_secs(60));
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000
MIT OR Apache-2.0