Skip to content

Latest commit

 

History

History
69 lines (48 loc) · 2.3 KB

File metadata and controls

69 lines (48 loc) · 2.3 KB

RustAPI Documentation

Welcome to the RustAPI documentation!

Quick Links

Document Description
Getting Started Build your first API in 5 minutes
Features Complete feature reference
Philosophy Design principles and decisions
Architecture Internal structure deep dive

What is RustAPI?

RustAPI is an ergonomic web framework for Rust, inspired by FastAPI's developer experience. It combines Rust's performance and safety with modern DX.

Key Features:

  • 🎯 5-line APIs — Minimal boilerplate
  • 🛡️ Type Safety — Compile-time guarantees
  • 📖 Auto Documentation — Swagger UI out of the box
  • 🤖 LLM-Ready — TOON format saves 50-58% tokens
  • 🔒 Production Ready — JWT, CORS, rate limiting included

Philosophy

"API surface is ours, engines can change."

RustAPI provides a stable, ergonomic public API. Internal dependencies (e.g., hyper, tokio, matchit) are implementation details that can be upgraded without breaking your code.

External Dependency Plan

To reduce external dependency debt, we prioritize replacing crates with stable specs and small surfaces, while keeping the public API unchanged. Validation already uses the native rustapi-validate engine; candidates for further RustAPI-owned implementations are routing, OpenAPI generation, the TOON format, and template rendering. Foundational runtime and HTTP crates (tokio, hyper, tower) remain external for stability and security.

Getting Started

[dependencies]
rustapi-rs = "0.1.4"
use rustapi_rs::prelude::*;

#[rustapi_rs::get("/hello/{name}")]
async fn hello(Path(name): Path<String>) -> Json<Message> {
    Json(Message { greeting: format!("Hello, {name}!") })
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    RustApi::auto().run("0.0.0.0:8080").await
}

Visit http://localhost:8080/docs for auto-generated Swagger UI.

Examples

See the examples directory:

  • hello-world — Minimal example
  • crud-api — Full CRUD operations
  • auth-api — JWT authentication
  • toon-api — LLM-optimized responses
  • proof-of-concept — Complete feature showcase

License

MIT or Apache-2.0, at your option.