【Rust】發現一個有趣的項目 salvo web framework
發現一個有趣的項目 salvo web framework
https://github.com/salvo-rs/salvo
-
支持基於 hyper、tokio 和 async;
-
支持 Websocket;
-
中間件是 handler,支持在 handle 之前或之後執行;
-
簡單易用的路由系統,路由器可以嵌套,可以在任意路由器上添加中間件;
-
支持 Multipart 表單,處理文件上傳非常簡單;
-
從許多物理目錄提供靜態虛擬目錄;
提供人性化 API, 感覺和 gin 有點像
use salvo::prelude::*;
#[fn_handler]
async fn hello_world() -> &'static str {
"Hello World"
}
#[tokio::main]
async fn main() {
let router = Router::new().get(hello_world);
let server = Server::new(router);
server.bind(([0, 0, 0, 0], 7878)).await;
}
本文由 Readfog 進行 AMP 轉碼,版權歸原作者所有。
來源:https://mp.weixin.qq.com/s/3xgTwZ7pv7x-_Bf8gagqVg