Created
July 5, 2020 01:49
-
-
Save rxw1/632488da266f3fc72c1873c388971218 to your computer and use it in GitHub Desktop.
Request Headers (Rust + Warp)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![deny(warnings)] | |
use warp::{ | |
Filter, | |
http::{ | |
HeaderMap, | |
Method | |
}, | |
path::{ | |
FullPath | |
} | |
}; | |
#[tokio::main] | |
async fn main() { | |
let headers = warp::header::headers_cloned() | |
.and(warp::method()) | |
.and(warp::path::full()) | |
.map(|headers: HeaderMap, method: Method, path: FullPath| { | |
format!("{}, {:?}, {:#?}", method, path, headers) | |
}); | |
let routes = warp::any() | |
.and(headers); | |
warp::serve(routes).run(([127, 0, 0, 1], 3333)).await; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment