| Crates.io | boluo |
| lib.rs | boluo |
| version | 0.7.0 |
| created_at | 2024-03-15 05:34:18.902424+00 |
| updated_at | 2025-05-07 07:28:19.10485+00 |
| description | 简单易用的异步网络框架 |
| homepage | https://github.com/dakai-chen/boluo |
| repository | https://github.com/dakai-chen/boluo |
| max_upload_size | |
| id | 1174437 |
| size | 221,011 |
简单易用的高性能异步网络框架
boluo 是一个基于 tokio 和 hyper 开发的轻量级路由层,几乎没有额外的性能开销,拥有极快的运行速度。
Service 和 Middleware,灵活且易于扩展。| 功能名 | 描述 | 默认启用 |
|---|---|---|
| http1 | 启用HTTP1服务器 | 是 |
| http2 | 启用HTTP2服务器 | |
| multipart | 添加对 multipart/form-data 格式的支持 |
|
| sse | 添加对服务器发送事件的支持 | |
| ws | 添加对网络套接字的支持 | |
| static-file | 添加对静态文件的支持 |
新建项目:
cargo new demo && cd demo
添加依赖:
[dependencies]
boluo = "0.7"
tokio = { version = "1", features = ["full"] }
用以下内容覆盖 src/main.rs:
use boluo::response::IntoResponse;
use boluo::route::Router;
use boluo::server::Server;
use tokio::net::TcpListener;
#[tokio::main]
async fn main() {
let listener = TcpListener::bind("127.0.0.1:3000").await.unwrap();
let app = Router::new().mount(hello);
Server::new(listener).run(app).await.unwrap();
}
#[boluo::route("/", method = "GET")]
async fn hello() -> impl IntoResponse {
"Hello, World!"
}
运行项目:
cargo run
访问服务:
curl http://127.0.0.1:3000/
在这里可以找到更多的示例代码。在示例目录中,你可以通过以下命令运行示例:
cargo run --bin hello
支持的最低 Rust 版本为 1.85.0。