Crates.io | stry-attrouter |
lib.rs | stry-attrouter |
version | 0.1.0 |
source | src |
created_at | 2020-12-26 02:33:30.031321 |
updated_at | 2020-12-26 02:33:30.031321 |
description | A attribute based router for various Rust web servers. |
homepage | |
repository | https://gitlab.com/stry-rs/attrouter |
max_upload_size | |
id | 327335 |
size | 23,174 |
Attrouter is an attribute based router for various Rust web servers.
Add stry-attrouter
, tokio
, and warp
to your dependencies:
stry-attrouter = { version = "0.1", default-features = false, features = [ "with-warp" ] }
tokio = { version = "0.2", features = ["full"] }
warp = "0.2"
And in your 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;
}