Rapina is a web framework for Rust inspired by FastAPI, focused on productivity, type safety, and clear conventions.
Quick Start
Or add to an existing project:
[]
= "0.2.0"
= { = "1", = ["full"] }
= { = "1", = ["derive"] }
use *;
async
async
async
Why Rapina?
| Principle | Description |
|---|---|
| Opinionated | Convention over configuration. Clear defaults, escape hatches when needed. |
| Type-safe | Typed extractors, typed errors, everything checked at compile time. |
| AI-friendly | Predictable patterns that humans and LLMs understand equally well. |
| Batteries-included | Standardized errors with trace_id, JWT auth, observability built-in. |
Project Status
This project is currently in Alpha 🚧.
We are committed to minimizing breaking changes to ensure a smooth developer experience. However, until the 1.0.0
release, major architectural changes may still happen if strictly necessary for long-term stability.
Features
Typed Extractors
Clean, type-safe parameter extraction:
async
async
async
Available extractors: Path, Json, Query, Form, Headers, State, CurrentUser
Configuration
Type-safe configuration with fail-fast validation:
Authentication
Protected by default — all routes require JWT unless marked #[public]:
async
async
new
.with_auth
.public_route
.router
.listen
.await
Standardized Errors
Every error includes a trace_id for debugging:
bad_request // 400
unauthorized // 401
not_found // 404
validation // 422
internal // 500
OpenAPI
Automatic OpenAPI 3.0 generation with CLI tools:
Rate Limiting
Protect your API from abuse with token bucket rate limiting:
new
.with_rate_limit
.router
.listen
.await
Returns 429 Too Many Requests with Retry-After header when exceeded.
Response Compression
Automatic gzip/deflate compression for large responses:
new
.with_compression
.router
.listen
.await
CLI
Documentation
Full documentation available at userapina.com
Philosophy
Rapina is opinionated by design: a clear happy path, with escape hatches when needed.
| Principle | Description |
|---|---|
| Predictability | Clear conventions, obvious structure |
| Auditability | Typed contracts, traceable errors |
| Security | Protected by default, guard rails built-in |
| AI-friendly | Patterns that LLMs can understand and generate |
License
MIT