Skip to content

Instantly share code, notes, and snippets.

@rxw1
Created July 5, 2020 01:49
Show Gist options
  • Save rxw1/632488da266f3fc72c1873c388971218 to your computer and use it in GitHub Desktop.
Save rxw1/632488da266f3fc72c1873c388971218 to your computer and use it in GitHub Desktop.
Request Headers (Rust + Warp)
#![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