Created
September 8, 2023 11:36
-
-
Save yanns/66da2fa07e568244d3554168237b812f to your computer and use it in GitHub Desktop.
complation error when using router.merge(...).layer(...)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0277]: the trait bound `axum::error_handling::HandleError<tower_http::decompression::RequestDecompression<axum::routing::Route>, [closure@src/main.rs:18:46: 18:59], _>: tower::Service<axum::http::Request<_>>` is not satisfied | |
--> src/main.rs:17:13 | |
| | |
16 | .layer( | |
| ----- required by a bound introduced by this call | |
17 | / ServiceBuilder::new() | |
18 | | .layer(HandleErrorLayer::new(|_: BoxError| async move { | |
19 | | (StatusCode::INTERNAL_SERVER_ERROR, "Unhandled server error") | |
20 | | })) | |
21 | | .layer(RequestDecompressionLayer::new()), | |
| |________________________________________________________^ the trait `tower::Service<axum::http::Request<_>>` is not implemented for `axum::error_handling::HandleError<tower_http::decompression::RequestDecompression<axum::routing::Route>, [closure@src/main.rs:18:46: 18:59], _>` | |
| | |
= help: the following other types implement trait `tower::Service<Request>`: | |
axum::error_handling::HandleError<S, F, ()> | |
axum::error_handling::HandleError<S, F, (T1,)> | |
axum::error_handling::HandleError<S, F, (T1, T2)> | |
axum::error_handling::HandleError<S, F, (T1, T2, T3)> | |
axum::error_handling::HandleError<S, F, (T1, T2, T3, T4)> | |
axum::error_handling::HandleError<S, F, (T1, T2, T3, T4, T5)> | |
axum::error_handling::HandleError<S, F, (T1, T2, T3, T4, T5, T6)> | |
axum::error_handling::HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7)> | |
and 9 others | |
note: the method call chain might not have had the expected associated types | |
--> src/main.rs:18:18 | |
| | |
17 | ServiceBuilder::new() | |
| --------------------- this expression has type `ServiceBuilder<Identity>` | |
18 | .layer(HandleErrorLayer::new(|_: BoxError| async move { | |
| __________________^ | |
19 | | (StatusCode::INTERNAL_SERVER_ERROR, "Unhandled server error") | |
20 | | })) | |
| |___________________^ `Layer::Service` is `HandleError<_, [closure@main.rs:18:46], _>` here | |
21 | .layer(RequestDecompressionLayer::new()), | |
| --------------------------------------- `Layer::Service` remains `HandleError<RequestDecompression<_>, [closure@main.rs:18:46], _>` here | |
note: required by a bound in `axum::Router::<S, B>::layer` | |
--> /Users/yannsimon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/mod.rs:236:21 | |
| | |
233 | pub fn layer<L, NewReqBody>(self, layer: L) -> Router<S, NewReqBody> | |
| ----- required by a bound in this associated function | |
... | |
236 | L::Service: Service<Request<NewReqBody>> + Clone + Send + 'static, | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Router::<S, B>::layer` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment