diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index 34ca6805ba..9c2027fc43 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -10,9 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **added:** Add `AppendHeaders` for appending headers to a response rather than overriding them ([#927]) - **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]) - **fixed:** Fix trailing slash redirection with query parameters ([#936]) [#901]: https://github.com/tokio-rs/axum/pull/901 +[#924]: https://github.com/tokio-rs/axum/pull/924 [#927]: https://github.com/tokio-rs/axum/pull/927 [#936]: https://github.com/tokio-rs/axum/pull/936 diff --git a/axum/src/routing/mod.rs b/axum/src/routing/mod.rs index 581e924133..df4352f340 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();