[dependencies]
futures-util = { version = "0.3", default-features = false, features = ["sink"] }
tokio = { version = "1", features = ["full"] }
+env_logger = "0.9"
warp = "0.3"
#[tokio::main]
async fn main() {
+ env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
+
// GET /hello/warp => 200 OK with body "Hello, warp!"
let hello = warp::path!("hello" / String)
.and(warp::header::<String>("user-agent"))
})
});
- warp::serve(hello.or(echo))
+ let api = hello
+ .or(echo)
+ .with(warp::log("warp-server"));
+
+ warp::serve(api)
.run(([127, 0, 0, 1], 3030))
.await;
}