1个不稳定版本
0.1.0 | 2020年12月26日 |
---|
#1101 在 进程宏
24KB
566 行
(stry) attrouter
Attrouter是一种适用于各种Rust网络服务器的基于属性的路由器。
网络服务器
- Tide
- Warp
示例
将stry-attrouter
、tokio
和warp
添加到您的依赖项
stry-attrouter = { version = "0.1", default-features = false, features = [ "with-warp" ] }
tokio = { version = "0.2", features = ["full"] }
warp = "0.2"
并在您的main.rs
// GET /hello/warp => 200 OK with body "Hello, warp!"
#[stry_attrouter::get("/hello/{name}")]
fn hello(name: String) -> impl warp::Reply {
format!("Hello, {}!", name)
}
#[tokio::main]
async fn main() {
warp::serve(hello())
.run(([127, 0, 0, 1], 3030))
.await;
}
依赖项
~1.5MB
~35K SLoC