From e7ebd4f6fb98bb426f12717f747e9106c6d80ee6 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sat, 11 Jun 2022 13:37:20 +0200 Subject: [PATCH] Allow `Error: Into` for `Route::{layer, route_layer}` (#948) * Allow `Error: Into` for `Route::{layer, route_layer}` (#924) * Allow `Error: Into` for `Route::{layer, route_layer}` Fixes https://github.com/tokio-rs/axum/issues/922 * changelog * fixup changelog --- axum/CHANGELOG.md | 5 +++++ axum/src/routing/mod.rs | 15 +++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index ac60ea38a6..c74667b986 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -30,14 +30,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 extractor ([#1078]) - **added:** Implement `IntoResponse` for `Form` ([#1095]) - **change:** axum's MSRV is now 1.56 ([#1098]) +- **breaking:** Remove `extractor_middleware` which was previously deprecated. + Use `axum::middleware::from_extractor` instead ([#1077]) +- **breaking:** Allow `Error: Into` for `Route::{layer, route_layer}` ([#924]) - **breaking:** Remove `extractor_middleware` which was previously deprecated. Use `axum::middleware::from_extractor` instead ([#1077]) [#1077]: https://github.com/tokio-rs/axum/pull/1077 [#1078]: https://github.com/tokio-rs/axum/pull/1078 [#1078]: https://github.com/tokio-rs/axum/pull/1078 +[#1078]: https://github.com/tokio-rs/axum/pull/1078 [#1095]: https://github.com/tokio-rs/axum/pull/1095 [#1098]: https://github.com/tokio-rs/axum/pull/1098 +[#924]: https://github.com/tokio-rs/axum/pull/924 # 0.5.7 (08. June, 2022) diff --git a/axum/src/routing/mod.rs b/axum/src/routing/mod.rs index 11ac540719..df9f8340b0 100644 --- a/axum/src/routing/mod.rs +++ b/axum/src/routing/mod.rs @@ -294,15 +294,15 @@ where pub fn layer(self, layer: L) -> Router where L: Layer>, - L::Service: Service, Response = Response, Error = Infallible> - + Clone - + Send - + 'static, + L::Service: + Service, Response = Response> + Clone + Send + 'static, + >>::Error: Into + 'static, >>::Future: Send + 'static, NewResBody: HttpBody + Send + 'static, NewResBody::Error: Into, { let layer = ServiceBuilder::new() + .map_err(Into::into) .layer(MapResponseBodyLayer::new(boxed)) .layer(layer) .into_inner(); @@ -335,15 +335,14 @@ where pub fn route_layer(self, layer: L) -> Self where L: Layer>, - L::Service: Service, Response = Response, Error = Infallible> - + Clone - + Send - + 'static, + L::Service: Service, Response = Response> + Clone + Send + 'static, + >>::Error: Into + 'static, >>::Future: Send + 'static, NewResBody: HttpBody + Send + 'static, NewResBody::Error: Into, { let layer = ServiceBuilder::new() + .map_err(Into::into) .layer(MapResponseBodyLayer::new(boxed)) .layer(layer) .into_inner();