From 247502c3caa812c434e727ac292fc3a5a7213051 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sat, 9 Apr 2022 12:40:34 +0200 Subject: [PATCH 1/2] Allow `Error: Into` for `Route::{layer, route_layer}` Fixes https://github.com/tokio-rs/axum/issues/922 --- axum/src/routing/mod.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/axum/src/routing/mod.rs b/axum/src/routing/mod.rs index 81a0270069..0f3572a117 100644 --- a/axum/src/routing/mod.rs +++ b/axum/src/routing/mod.rs @@ -291,15 +291,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(); @@ -332,15 +332,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(); From 29151423926de912ac310a9b1cac9a90564b215e Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sun, 17 Apr 2022 23:08:58 +0200 Subject: [PATCH 2/2] changelog --- axum/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index c87064f41f..f3bf34e7b3 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -9,8 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **added:** Add `axum::extract::multipart::Field::chunk` method for streaming a single chunk from the field ([#901]) +- **changed:** Allow `Error: Into` for `Route::{layer, route_layer}` ([#924]) [#901]: https://github.com/tokio-rs/axum/pull/901 +[#924]: https://github.com/tokio-rs/axum/pull/924 # 0.5.1 (03. April, 2022)