feat: add warp
This commit is contained in:
1295
warp/Cargo.lock
generated
Normal file
1295
warp/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
warp/Cargo.toml
Normal file
12
warp/Cargo.toml
Normal 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
warp/README.md
Normal file
4
warp/README.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
warp: https://crates.io/crates/warp
|
||||||
|
|
||||||
|
|
||||||
13
warp/src/main.rs
Normal file
13
warp/src/main.rs
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user