rustapi-extras
Optional security and utility features for the RustAPI framework.
Features
This crate provides production-ready middleware and utilities that are opt-in via Cargo feature flags to minimize binary size when not needed.
Available Features
jwt- JWT authentication middleware andAuthUser<T>extractorcors- CORS middleware with builder pattern configurationrate-limit- IP-based rate limiting middlewareconfig- Configuration management with.envfile supportcookies- Cookie parsing extractorextras- Meta feature enabling jwt, cors, and rate-limitfull- All features enabled
Usage
Add to your Cargo.toml:
[]
= { = "0.1", = ["jwt", "cors"] }
Examples
JWT Authentication
use ;
use Deserialize;
async
CORS Configuration
use CorsLayer;
use Method;
let cors = new
.allow_origins
.allow_methods
.allow_credentials;
Rate Limiting
use RateLimitLayer;
use Duration;
// Allow 100 requests per minute per IP
let rate_limit = new;
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.