mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-23 00:00:15 +02:00
Improve compile times (#184)
* Inline `handler::IntoService` * Inline `BoxResponseBody` * Add missing debug impl
This commit is contained in:
@@ -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
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user