Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

rapina

> 编程语言
Open source

A Rust web framework for APIs. So simple it feels like cheating.

176 stars0 likes0 views
WebsiteGitHub

About

A Rust web framework for APIs. So simple it feels like cheating.

Rapina

A Rust web framework for APIs. So simple it feels like cheating.


rust
use rapina::prelude::*;

#[get("/users")]
async fn list_users(db: Db) -> Result>> {
    let users = User::find_all(db.conn()).await?;
    Ok(Json(users))
}

#[post("/users")]
async fn create_user(input: Validated>, db: Db) -> Result> {
    let user = User::create(db.conn(), input.into_inner()).await?;
    Ok(Json(user))
}

#[tokio::main]
async fn main() -> std::io::Result {
    Rapina::new()
        .discover()
        .listen("127.0.0.1:3000")
        .await
}

No router configuration. No manual wiring. Annotate your handlers, call .discover(), ship.

Get started

bash
cargo install rapina-cli
rapina new my-app
cd my-app
rapina dev

Your API is running. That's it.

What you get

Auto-discovery — annotate handlers with #[get], #[post], #[put], #[delete]. Rapina finds them at startup. Your main.rs stays three lines.

Database from day one — define your schema declaratively. author: User becomes a foreign key. posts: Vec becomes a relationship. SeaORM entities are auto-generated.

rust
schema! {
    User {
        name: String,
        email: String,
        posts: Vec
    }

    Post {
        title: String,
        body: String,
        author: User
    }
}

Auth that works — JWT authentication, protected by default. Mark public routes with #[public]. Access the current user with the CurrentUser extractor.

rust
#[public]
#[post("/login")]
async fn login(body: Json, auth: State) -> Result> {
    let token = auth.create_token(&body.username)?;
    Ok(Json(TokenResponse::new(token, auth.expiration())))
}

#[get("/me")]
async fn me(user: CurrentUser) -> Json {
    Json(UserResponse { id: user.id })
}

CRUD in one command — scaffold an entire resource with handlers, DTOs, errors, schema, and migration.

bash
rapina add resource Post

OpenAPI built-in — spec generation, breaking change detection, and validation from the CLI.

bash
rapina openapi export -o openapi.json
rapina openapi diff --base main

Production middleware — rate limiting, compression, CORS out of the box. Prometheus metrics available with the metrics feature flag.

rust
Rapina::new()
    .with_rate_limit(RateLimitConfig::per_minute(100))
    .with_compression(CompressionConfig::default())
    .with_cors(CorsConfig::permissive())
    .with_metrics(true)  // Requires `metrics` feature flag
    .discover()
    .listen("0.0.0.0:3000")
    .await

CLI for everything — create, develop, test, inspect, generate.

bash
rapina new my-app              # Scaffold a new project
rapina dev                     # Dev server with hot reload
rapina test --coverage         # Tests with coverage report
rapina test --watch            # Watch mode
rapina routes                  # List all routes
rapina doctor                  # Health checks and diagnostics
rapina migrate new             # Create a migration
rapina add resource Post       # Full CRUD scaffolding

Built-in extractors

Everything you need to pick apart a request, type-safe and compile-time checked.

Json · Path · Query · Headers · Cookie · State · CurrentUser · Db · ... and more

See the extractors documentation for the full list.

Standardized errors

Every error includes a trace_id. No more guessing in production.

json
{
  "error": { "code": "NOT_FOUND", "message": "user not found" },
  "trace_id": "550e8400-e29b-41d4-a716-446655440000"
}

Project status

Rapina is in active development with a rapid release cadence. The API is stabilizing but breaking changes may still occur before 1.0.0.

See the roadmap for what's coming next.

Documentation

Full documentation at userapina.com

  • Getting Started
  • Database
  • Authentication
  • CLI Reference

Contributing

Contributions are welcome. Check out the open issues or join us on Discord.

License

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustapiframeworkhttprust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言