Scripts2026年7月1日·1 分钟阅读

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.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Salvo Rust Framework
直接安装命令
npx -y tokrepo@latest install 6072d394-7569-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产