r/ForgeYourProject • u/IncomeOk7237 • 16d ago
Launch RustAPI: my Rust web framework where simple routes skip the middleware chain and every endpoint is also an MCP tool
Besides Viltrum, the other web framework I work on is RustAPI. It's a Rust framework on top of hyper 1.x and tokio, and it's at v0.2.2 on crates.io now, so it felt like time to give it its own post here.
The starting idea was basically "FastAPI ergonomics with Rust performance". You write a small handler, put #[rustapi_rs::get("/...")] on it, and it gets registered at link time (a linkme distributed slice), so there's no manual router wiring. OpenAPI docs show up at /docs on their own.
A few things I care about in it:
- Three execution paths per request. If a route has no middleware and no interceptors, the handler is called directly with no Arc cloning. Only routes that actually use layers (JWT, CORS, rate limiting) go through the full stack. So your /health doesn't pay for your auth.
- Facade crate. User code only imports
rustapi-rs, so the internal crates can change underneath. The public API is tracked with cargo public-api snapshots, and CI makes any PR that changes it carry a breaking/feature label. - Every endpoint is also an MCP tool. In-process calls come in around 28 µs vs about 1.3 ms through a proxy.
- TOON, a compact response format for LLM use that cuts token counts by roughly 50-58% compared to JSON, with headers that report the savings.
- Request replay. A middleware records request/response pairs, then you can replay or diff them against staging from the CLI.
Recent work has been the boring but necessary kind: v0.2.2 closed a RUSTSEC advisory with a rustls bump, and coverage moved from tarpaulin to cargo-llvm-cov because tarpaulin kept segfaulting on GitHub Actions.
Repo: https://github.com/Tuntii/RustAPI
If you build APIs with Axum or Actix, what would actually make you try a new framework? And is "every endpoint is an MCP tool" useful to you or just noise?