Introduction
Salvo is a Rust web framework that bundles routing, middleware, static file serving, WebSockets, TLS, and OpenAPI doc generation into one crate. Built on Hyper and Tokio, it targets developers who want a batteries-included framework without pulling in dozens of separate dependencies.
What Salvo Does
- Routes requests using a tree-based router with path parameters and wildcards
- Provides a
#[handler]macro for ergonomic endpoint definitions - Supports middleware (called Handlers in Salvo) with before, after, and around semantics
- Generates OpenAPI documentation from handler signatures and annotations
- Serves static files, handles WebSocket upgrades, and supports HTTP/3 via QUIC
Architecture Overview
Salvo is layered on top of Hyper for HTTP parsing and Tokio for async I/O. Incoming connections are accepted by a listener (TCP, TLS, or QUIC), requests are dispatched through a tree router, and handlers execute as async functions returning types that implement the Scribe trait. The framework uses a depot (typed map) to pass data between handlers in a request pipeline.
Self-Hosting & Configuration
- Requires Rust 1.75+ with Tokio runtime
- Add
salvoto Cargo.toml; feature flags enable TLS, HTTP/3, and OpenAPI - Configure listeners for plain TCP, Rustls TLS, or Quinn-based QUIC
- Use
Router::new()to build route trees with.push()for nesting - Deploy as a static binary; add a reverse proxy for edge TLS if preferred
Key Features
- OpenAPI spec generation directly from handler code via the
oapifeature - Built-in support for ACME (Let's Encrypt) automatic certificate provisioning
- HTTP/3 and QUIC support without external proxies
- Depot (typed map) shares data between middleware handlers within a request
- Extractors parse query strings, JSON bodies, multipart forms, and path params
Comparison with Similar Tools
- Actix Web — more mature ecosystem; Salvo has more built-in features like OpenAPI and HTTP/3
- Axum — Tower-based extractor pattern; Salvo uses a handler macro and depot approach
- Rocket — macro-heavy with Fairings; Salvo offers a flatter middleware model
- Poem — similar batteries-included philosophy; Salvo adds HTTP/3 and ACME
- Warp — filter combinators; Salvo uses conventional routing
FAQ
Q: How stable is Salvo for production use? A: Salvo has not reached 1.0 but is actively developed and used in production by early adopters. Pin your version in Cargo.toml to avoid breaking changes.
Q: Does Salvo support Tokio or async-std? A: Salvo is built on Tokio exclusively. It does not support async-std.
Q: How does OpenAPI generation work?
A: Enable the oapi feature, annotate handlers with #[endpoint], and Salvo generates a JSON/YAML OpenAPI spec served at a configurable path.
Q: Can I use Salvo for WebSocket applications? A: Yes. Salvo includes WebSocket support via a built-in handler that upgrades HTTP connections.