feat: add warp

This commit is contained in:
2020-08-29 10:23:30 +08:00
parent 6e7909f04d
commit 5ece072af9
4 changed files with 1324 additions and 0 deletions
+1295
View File
File diff suppressed because it is too large Load Diff
+12
View File
@@ -0,0 +1,12 @@
[package]
name = "warp"
version = "0.1.0"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
warp = "0.2.4"
tokio = { version = "0.2", features = ["macros"] }
+4
View File
@@ -0,0 +1,4 @@
warp: https://crates.io/crates/warp
+13
View File
@@ -0,0 +1,13 @@
use warp::Filter;
#[tokio::main]
async fn main() {
// GET /hello/warp => 200 OK with body "Hello, warp!"
let hello = warp::path!("hello" / String)
.map(|name| format!("Hello, {}!", name));
warp::serve(hello)
.run(([127, 0, 0, 1], 8080))
.await;
}