mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-24 00:00:16 +02:00
Fix compile time regression by boxing routes internally (#404)
This is a reimplementation of #401 but with the new matchit based router. Fixes #399
This commit is contained in:
+9
-7
@@ -25,8 +25,8 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
use tower::service_fn;
|
||||
use tower::timeout::TimeoutLayer;
|
||||
use tower::{service_fn, ServiceBuilder};
|
||||
use tower_service::Service;
|
||||
|
||||
pub(crate) use helpers::*;
|
||||
@@ -251,8 +251,7 @@ async fn boxing() {
|
||||
"hi from POST"
|
||||
}),
|
||||
)
|
||||
.layer(tower_http::compression::CompressionLayer::new())
|
||||
.boxed();
|
||||
.layer(tower_http::compression::CompressionLayer::new());
|
||||
|
||||
let client = TestClient::new(app);
|
||||
|
||||
@@ -532,10 +531,13 @@ async fn wildcard_sees_whole_url() {
|
||||
async fn middleware_applies_to_routes_above() {
|
||||
let app = Router::new()
|
||||
.route("/one", get(std::future::pending::<()>))
|
||||
.layer(TimeoutLayer::new(Duration::new(0, 0)))
|
||||
.layer(HandleErrorLayer::new(|_: BoxError| {
|
||||
StatusCode::REQUEST_TIMEOUT
|
||||
}))
|
||||
.layer(
|
||||
ServiceBuilder::new()
|
||||
.layer(HandleErrorLayer::new(|_: BoxError| {
|
||||
StatusCode::REQUEST_TIMEOUT
|
||||
}))
|
||||
.layer(TimeoutLayer::new(Duration::new(0, 0))),
|
||||
)
|
||||
.route("/two", get(|| async {}));
|
||||
|
||||
let client = TestClient::new(app);
|
||||
|
||||
Reference in New Issue
Block a user