Make Request<Body> an extractor

This commit is contained in:
David Pedersen
2021-06-09 09:42:06 +02:00
parent 90c3e5ba74
commit c91dc7ce29
10 changed files with 268 additions and 200 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
use http::{Request, StatusCode};
use http::StatusCode;
use hyper::Server;
use std::net::SocketAddr;
use tower::make::Shared;
@@ -18,11 +18,11 @@ async fn main() {
server.await.unwrap();
}
async fn handler(_req: Request<Body>) -> response::Html<&'static str> {
async fn handler() -> response::Html<&'static str> {
response::Html("<h1>Hello, World!</h1>")
}
async fn greet(_req: Request<Body>, params: extract::UrlParamsMap) -> Result<String, StatusCode> {
async fn greet(params: extract::UrlParamsMap) -> Result<String, StatusCode> {
if let Some(name) = params.get("name") {
Ok(format!("Hello {}!", name))
} else {