Improve compile times (#184)

* Inline `handler::IntoService`

* Inline `BoxResponseBody`

* Add missing debug impl
This commit is contained in:
David Pedersen
2021-08-15 23:01:26 +02:00
committed by GitHub
parent 292d174a73
commit 48afd30491
7 changed files with 191 additions and 257 deletions
+8 -6
View File
@@ -39,17 +39,19 @@ mod for_handlers {
mod for_services {
use super::*;
use crate::service::get;
use headers::HeaderValue;
#[tokio::test]
async fn get_handles_head() {
let app = route(
"/",
get((|| async {
let mut headers = HeaderMap::new();
headers.insert("x-some-header", "foobar".parse().unwrap());
(headers, "you shouldn't see this")
})
.into_service()),
get(service_fn(|req: Request<Body>| async move {
let res = Response::builder()
.header("x-some-header", "foobar".parse::<HeaderValue>().unwrap())
.body(Body::from("you shouldn't see this"))
.unwrap();
Ok::<_, Infallible>(res)
})),
);
// don't use reqwest because it always strips bodies from HEAD responses
+1 -4
View File
@@ -354,10 +354,7 @@ async fn routing_between_services() {
}),
),
)
.route(
"/two",
service::on(MethodFilter::GET, handle.into_service()),
);
.route("/two", service::on(MethodFilter::GET, any(handle)));
let addr = run_in_background(app).await;