Rapina
Predictable, auditable, and secure APIs — written by humans, accelerated by AI.
Rapina is a web framework for Rust inspired by FastAPI, focused on productivity, type safety, and clear conventions.
Installation
Add Rapina to your Cargo.toml:
[]
= "0.1.0-alpha.3"
= { = "1", = ["full"] }
= { = "1", = ["derive"] }
Or use the CLI to create a new project:
Why Rapina?
- Opinionated — Convention over configuration. 90% of apps require 10% of decisions.
- Type-safe — Typed extractors, typed errors, everything checked at compile time.
- AI-friendly — Predictable structure that humans and models understand.
- Production-ready — Standardized errors with
trace_id, ready for observability.
Quick Start
use *;
async
Features
CLI Tools
Rapina comes with a powerful CLI for development:
# Install the CLI
# Create a new project
# Start development server with hot reload
# Custom port and host
# OpenAPI tools
Typed Extractors
// Path parameters
new.get;
// JSON body
new.post;
// Query parameters
new.get;
// Application state
new.get;
Available extractors: Json, Path, Query, Form, Headers, State, Context
Middleware
use ;
use Duration;
new
.middleware
.middleware
.middleware // 1MB
.router
.listen
.await
Standardized Errors
Every error returns a consistent envelope with trace_id:
Built-in error constructors:
bad_request // 400
unauthorized // 401
forbidden // 403
not_found // 404
conflict // 409
validation // 422
rate_limited // 429
internal // 500
Route Introspection
Enable introspection to see all registered routes:
new
.with_introspection // Enabled by default in debug builds
.router
.listen
.await
Access routes at http://localhost:3000/__rapina/routes:
OpenAPI Specification
Rapina automatically generates OpenAPI 3.0 specs from your code:
// Add JsonSchema for response schemas
async
new
.openapi // Enable OpenAPI
.router
.listen
.await
Access the spec at http://localhost:3000/__rapina/openapi.json
CLI Tools for API Contract Management:
# Export OpenAPI spec to file
# Check if committed spec matches current code
# Detect breaking changes against another branch
Breaking change detection:
)
The openapi.json file becomes your API contract — commit it to your repo and CI will catch breaking changes before they're merged.
Testing
Built-in test client for integration testing:
use TestClient;
async
Application State
new
.state
.router
.listen
.await
Roadmap
- Basic router with path parameters
- Extractors (
Json,Path,Query,Form,Headers,State,Context) - Standardized error handling with
trace_id - Middleware system (
Timeout,BodyLimit,TraceId) - Dependency Injection / State
- Request context with tracing
- Route introspection endpoint
- Test client for integration testing
- CLI (
rapina new,rapina dev) - Automatic OpenAPI with response schemas
- OpenAPI CLI tools (
export,check,diff) - Validation (
Validated<T>) - Auth (Bearer JWT,
CurrentUser) - Observability (tracing, structured logs)
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 | Guard rails by default |
License
MIT