salvo_core (0.93.0)
Published 2026-08-13 09:24:32 +00:00 by agents
Installation
[registries.forgejo]
index = "sparse+ " # Sparse index
# index = " " # Git
[net]
git-fetch-with-cli = truecargo add salvo_core@0.93.0 --registry forgejoAbout this package
Salvo is a powerful web framework that can make your work easier.
Features
- Simple & Powerful - Minimal boilerplate. If you can write a function, you can write a handler.
- HTTP/1, HTTP/2 & HTTP/3 - Full protocol support out of the box.
- Flexible Routing - Tree-based routing with middleware support at any level.
- Auto TLS - ACME integration for automatic certificate management.
- OpenAPI - First-class OpenAPI support with auto-generated documentation.
- WebSocket & WebTransport - Real-time communication built-in.
- Built on Hyper & Tokio - Production-ready async foundation.
Quick Start
Create a new project:
cargo new hello-salvo
cd hello-salvo
cargo add salvo tokio --features salvo/oapi,tokio/macros
Write your first app in src/main.rs:
use salvo::prelude::*;
#[handler]
async fn hello() -> &'static str {
"Hello World"
}
#[tokio::main]
async fn main() {
let router = Router::new().get(hello);
let acceptor = TcpListener::new("127.0.0.1:7878").bind().await;
Server::new(acceptor).serve(router).await;
}
Run it:
cargo run
Why Salvo?
Middleware = Handler
No complex traits or generics. Middleware is just a handler:
#[handler]
async fn add_header(res: &mut Response) {
res.headers_mut().insert(header::SERVER, HeaderValue::from_static("Salvo"));
}
Router::new().hoop(add_header).get(hello)
Tree Routing with Middleware
Apply middleware to specific route branches:
Router::new()
// Public routes
.push(Router::with_path("articles").get(list_articles))
// Protected routes
.push(Router::with_path("articles").hoop(auth_check).post(create_article).delete(delete_article))
JSON APIs
Salvo handlers can deserialize request bodies and return typed JSON responses:
use salvo::http::ParseError;
use salvo::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct CreateTodo {
text: String,
}
#[derive(Serialize)]
struct Todo {
id: u64,
text: String,
}
#[handler]
async fn create_todo(req: &mut Request) -> Result<Json<Todo>, ParseError> {
let payload = req.parse_json::<CreateTodo>().await?;
Ok(Json(Todo {
id: 1,
text: payload.text,
}))
}
For this pattern, add Serde's derive feature:
cargo add serde --features derive
OpenAPI in One Line
Just change #[handler] to #[endpoint]:
#[endpoint]
async fn hello() -> &'static str {
"Hello World"
}
Auto HTTPS with ACME
Get TLS certificates automatically from Let's Encrypt:
let listener = TcpListener::new("0.0.0.0:443")
.acme()
.add_domain("example.com")
.http01_challenge(&mut router)
.quinn("0.0.0.0:443"); // HTTP/3 support
CLI Tool
cargo install salvo-cli
salvo new my_project
Learn More
Recommended Projects
- Savhub - Easily manage your AI skills. A platform built with Salvo for organizing and sharing AI capabilities.
- Palpo - A Matrix server implementation in Rust, powered by Salvo.
Check out the full list of community projects in our ECOSYSTEM.md.
Performance
Salvo consistently ranks among the fastest Rust web frameworks:
Support
If you find Salvo useful, consider buying me a coffee.
License
Licensed under Apache License 2.0.
Dependencies
| ID | Version |
|---|---|
| anyhow | ^1 |
| arc-swap | ^1.9 |
| async-trait | ^0.1 |
| base64 | ^0.22 |
| brotli | ^8 |
| bytes | ^1 |
| chardetng | ^1.0 |
| content_inspector | ^0.2 |
| cookie | ^0.18 |
| encoding_rs | ^0.8 |
| enumflags2 | ^0.7 |
| eyre | ^0.6 |
| flate2 | ^1 |
| form_urlencoded | ^1 |
| futures-channel | ^0.3 |
| futures-util | ^0.3 |
| h3-datagram | ^0.0.2 |
| headers | ^0.4 |
| http | ^1 |
| http-body-util | ^0.1 |
| hyper | ^1 |
| hyper-util | ^0.1 |
| indexmap | ^2 |
| mime | ^0.3 |
| mime-infer | ^4 |
| multimap | ^0.10 |
| multra | ^1 |
| native-tls | ^0.2 |
| openssl | ^0.10 |
| parking_lot | ^0.12 |
| percent-encoding | ^2 |
| pin-project | ^1 |
| quinn | ^0.11 |
| rand | ^0.10 |
| regex | ^1 |
| salvo-http3 | ^0.7.0 |
| salvo_macros | ^0.93.0 |
| serde | ^1 |
| serde-xml-rs | ^0.8 |
| serde_json | ^1 |
| serde_urlencoded | ^0.7 |
| socket2 | ^0.6 |
| sync_wrapper | ^1 |
| tempfile | >=3.20 |
| thiserror | ^2 |
| tokio | ^1 |
| tokio-native-tls | ^0.3 |
| tokio-openssl | ^0.6 |
| tokio-rustls | ^0.26 |
| tokio-util | ^0.7 |
| tracing | ^0.1 |
| url | ^2 |
| zstd | ^0.13 |
| fastrand | ^2 |
| rustls | ^0.23 |
| nix | ^0.31 |
Keywords
http
async
web
framework
server
Details
2026-08-13 09:24:32 +00:00
Assets (1)
Versions (1)
View all
Cargo
44
chrislearn <chris@acroidea.com>
driftluo <driftluo@foxmail.com>
Apache-2.0
204 KiB
salvo_core-0.93.0.crate
204 KiB
0.93.0
2026-08-13