88 releases (50 stable)
Uses new Rust 2024
| 2.12.0 | Dec 11, 2025 |
|---|---|
| 2.11.0 | Nov 18, 2025 |
| 2.10.1 | Oct 23, 2025 |
| 2.5.2 | Jul 14, 2025 |
| 0.10.8 | Jul 31, 2023 |
#134 in HTTP server
Used in silent-openapi
525KB
13K
SLoC
概要
Silent 是一个简单的基于Hyper的Web框架,它的目标是提供一个简单的、高效的、易于使用的Web框架。
文档
目标
- 路由
- 中间件
- 静态文件
- WebSocket
- 模板
- 日志 (使用了tracing)
- 配置
- 会话
- 安全
- GRPC
- 通用网络层 (NetServer)
- Cloudflare Worker
NetServer
提供与协议无关的通用网络服务器,支持 TCP、Unix Socket 等多种监听方式,并内置连接限流和优雅关停功能。
基本用法
use silent::NetServer;
use std::time::Duration;
#[tokio::main]
async fn main() {
NetServer::new()
.bind("127.0.0.1:8080".parse().unwrap())
.with_rate_limiter(10, Duration::from_millis(10), Duration::from_secs(2))
.with_shutdown(Duration::from_secs(5))
.serve(|mut stream, peer| async move {
println!("Connection from: {}", peer);
// 处理连接...
Ok(())
})
.await;
}
功能特性
- 多监听器支持: 同时监听多个 TCP 或 Unix Socket 地址
- 连接限流: 基于令牌桶算法的 QPS 限制
- 优雅关停: 支持 Ctrl-C 和 SIGTERM 信号,可配置等待时间
- 协议无关: 通过
ConnectionServicetrait 支持任意应用层协议
示例
Extractors(萃取器)
文档
security
argon2
add make_password and verify_password function
pbkdf2
add make_password and verify_password function
aes
re-export aes/aes_gcm
rsa
re-export rsa
configs
setting
use silent::Configs;
let mut configs = Configs::default ();
configs.insert(1i32);
usage
async fn call(req: Request) -> Result<i32> {
let num = req.configs().get::<i32>().unwrap();
Ok(*num)
}
examples for llm
complex projects for llm
Dependencies
~21–47MB
~701K SLoC