| Crates.io | rustapi-extras |
| lib.rs | rustapi-extras |
| version | 0.1.207 |
| created_at | 2025-12-31 03:22:01.291946+00 |
| updated_at | 2026-01-26 00:03:08.215617+00 |
| description | Production-ready middleware collection for RustAPI. Includes JWT auth, CORS, Rate Limiting, SQLx integration, and OpenTelemetry observability. |
| homepage | https://github.com/Tuntii/RustAPI |
| repository | https://github.com/Tuntii/RustAPI |
| max_upload_size | |
| id | 2013824 |
| size | 644,877 |
Production-ready middleware and utilities for RustAPI.
This crate provides optional "batteries" that you can enable to build robust applications.
Enable these in your Cargo.toml.
| Feature | Description | Dependencies |
|---|---|---|
jwt |
JSON Web Token authentication extractor & middleware | jsonwebtoken |
cors |
Cross-Origin Resource Sharing middleware | tower-http |
rate-limit |
IP-based rate limiting | governor / dashmap |
sqlx |
Database integration helpers | sqlx |
config |
Typed configuration loading from env/files | config, dotenvy |
otel |
OpenTelemetry observability integration | opentelemetry |
use rustapi_rs::prelude::*;
use rustapi_extras::jwt::{JwtAuth, AuthUser};
#[derive(Serialize, Deserialize)]
struct Claims {
sub: String,
exp: usize,
}
#[get("/protected")]
async fn protected_route(auth: AuthUser<Claims>) -> impl Responder {
format!("Hello user {}", auth.sub)
}
use rustapi_extras::cors::CorsLayer;
RustApi::new()
.layer(CorsLayer::permissive())
// ...