X-Git-Url: https://piware.de/gitweb/?p=learn-rust.git;a=blobdiff_plain;f=warp-server%2Fsrc%2Fmain.rs;fp=warp-server%2Fsrc%2Fmain.rs;h=a89c7a6fd205e4703d04ed7f38a9232799dbd69a;hp=70b3cc3f516dbf3bfb622a7f2231435682b0d609;hb=b2728f732e28cdd993c35870bf8cd5369f43a801;hpb=660eb0d2c9664a89a379f0d65923a4c8721a20b8 diff --git a/warp-server/src/main.rs b/warp-server/src/main.rs index 70b3cc3..a89c7a6 100644 --- a/warp-server/src/main.rs +++ b/warp-server/src/main.rs @@ -4,7 +4,8 @@ use warp::Filter; async fn main() { // GET /hello/warp => 200 OK with body "Hello, warp!" let hello = warp::path!("hello" / String) - .map(|name| format!("Hello, {}!", name)); + .and(warp::header::("user-agent")) + .map(|name, agent| format!("Hello, {} from {}!", name, agent)); warp::serve(hello) .run(([127, 0, 0, 1], 3030))