foortex.codegen utility
RustSystems 1650 18.9k

Rust Axum Redis Token Bucket Rate Limiting Middleware

Ultra-low overhead Rust rate limiter middleware for Axum Web Framework. Employs Redis atomic Lua scripts for sub-millisecond sliding window calculation, returning HTTP 429 Too Many Requests with canonical X-RateLimit-* headers.

Zero-allocation path matching
Atomic Redis Lua script execution
Interactive Prompt & Options
Fully Editable

Appended directly to the LLM system prompt for tailored code output.

✨ OpenRouter LLM Engine (Llama-3.3-70B) Active

Generated Code

⚡ Instant Boilerplate
rust-axum-rate-limiter.rs
1use axum::{http::{Request, StatusCode}, response::Response, middleware::Next, body::Body};
2use redis::AsyncCommands;
3
4pub async fn rate_limit_middleware(req: Request<Body>, next: Next) -> Result<Response, StatusCode> {
5 Ok(next.run(req).await)
6}
7
7 lines • 249 bytesrust
Automated Sandbox

Deploy this boilerplate automatically in 1 click.

Deploy