]> piware.de Git - learn-rust.git/blobdiff - warp-server/src/main.rs
warp-server: Initial hello world
[learn-rust.git] / warp-server / src / main.rs
diff --git a/warp-server/src/main.rs b/warp-server/src/main.rs
new file mode 100644 (file)
index 0000000..70b3cc3
--- /dev/null
@@ -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;
+}