From b2728f732e28cdd993c35870bf8cd5369f43a801 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 1 Nov 2022 16:30:53 +0100 Subject: [PATCH] warp-server: Add User-Agent header filter --- warp-server/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)) -- 2.39.5