# Salvo — Powerful Rust Web Framework with Built-In Features > Salvo is a Rust web framework built on Hyper and Tokio that provides a rich feature set including routing, middleware, WebSockets, TLS, HTTP/3, and OpenAPI generation in a single cohesive package. ## Install Save as a script file and run: # Salvo — Powerful Rust Web Framework with Built-In Features ## Quick Use ```toml # Cargo.toml [dependencies] salvo = "0.72" tokio = { version = "1", features = ["macros"] } ``` ```rust use salvo::prelude::*; #[handler] async fn hello() -> &'static str { "Hello, Salvo!" } #[tokio::main] async fn main() { let router = Router::new().get(hello); let acceptor = TcpListener::new("127.0.0.1:5800").bind().await; Server::new(acceptor).serve(router).await; } ``` ## 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 `salvo` to 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 `oapi` feature - 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. ## Sources - https://github.com/salvo-rs/salvo - https://salvo.rs/ --- Source: https://tokrepo.com/en/workflows/asset-6072d394 Author: Script Depot