2 个版本
0.6.2 | 2024 年 7 月 17 日 |
---|---|
0.6.1 | 2024 年 7 月 17 日 |
#921 in Web 编程
每月 215 次下载
92KB
2K SLoC
axum-serveplus
axum-serveplus
是 axum-server
项目的分支。它是一个旨在与 axum
框架配合使用的高性能 hyper 服务器实现。此分支旨在继续原始项目的发展和维护,确保与未来的 axum
版本兼容,并提供高性能和安全功能。
功能
- HTTP/1 和 HTTP/2
- 通过
rustls
支持 HTTPS - 通过
hyper
实现高性能 - 使用
tower
创建服务 API - 与
axum
兼容性非常好。很可能与未来的axum
版本兼容。
使用示例
一个简单的 hello world 应用程序可以像这样提供
use axum::{routing::get, Router};
use std::net::SocketAddr;
#[tokio::main]
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_serveplus::bind(addr)
.serve(app.into_make_service())
.await
.unwrap();
}
您可以在 这里 找到更多示例。
最低支持的 Rust 版本
axum-serveplus
的 MSRV 是 1.63。
安全性
此 crate 使用 #![forbid(unsafe_code)]
确保所有内容都在 100% 安全的 Rust 中实现。
许可证
本项目采用 MIT 许可证。
依赖关系
~7–19MB
~254K SLoC