From 660eb0d2c9664a89a379f0d65923a4c8721a20b8 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 1 Nov 2022 16:15:39 +0100 Subject: [PATCH] warp-server: Initial hello world --- warp-server/Cargo.toml | 10 ++++++++++ warp-server/src/main.rs | 12 ++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 warp-server/Cargo.toml create mode 100644 warp-server/src/main.rs diff --git a/warp-server/Cargo.toml b/warp-server/Cargo.toml new file mode 100644 index 0000000..ffbe552 --- /dev/null +++ b/warp-server/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "warp-server" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +tokio = { version = "1", features = ["full"] } +warp = "0.3" diff --git a/warp-server/src/main.rs b/warp-server/src/main.rs new file mode 100644 index 0000000..70b3cc3 --- /dev/null +++ b/warp-server/src/main.rs @@ -0,0 +1,12 @@ +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], 3030)) + .await; +} -- 2.39.5