Allow Error: Into<Infallible> for Route::{layer, route_layer} (#948)

* Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}` (#924)

* Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}`

Fixes https://github.com/tokio-rs/axum/issues/922

* changelog

* fixup changelog
This commit is contained in:
David Pedersen 2022-06-11 13:37:20 +02:00
parent 56ddabcd7d
commit 661473dcbc
2 changed files with 12 additions and 8 deletions

View file

@ -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<Infallible>` 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)

View file

@ -294,15 +294,15 @@ where
pub fn layer<L, NewReqBody, NewResBody>(self, layer: L) -> Router<NewReqBody>
where
L: Layer<Route<B>>,
L::Service: Service<Request<NewReqBody>, Response = Response<NewResBody>, Error = Infallible>
+ Clone
+ Send
+ 'static,
L::Service:
Service<Request<NewReqBody>, Response = Response<NewResBody>> + Clone + Send + 'static,
<L::Service as Service<Request<NewReqBody>>>::Error: Into<Infallible> + 'static,
<L::Service as Service<Request<NewReqBody>>>::Future: Send + 'static,
NewResBody: HttpBody<Data = Bytes> + Send + 'static,
NewResBody::Error: Into<BoxError>,
{
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<L, NewResBody>(self, layer: L) -> Self
where
L: Layer<Route<B>>,
L::Service: Service<Request<B>, Response = Response<NewResBody>, Error = Infallible>
+ Clone
+ Send
+ 'static,
L::Service: Service<Request<B>, Response = Response<NewResBody>> + Clone + Send + 'static,
<L::Service as Service<Request<B>>>::Error: Into<Infallible> + 'static,
<L::Service as Service<Request<B>>>::Future: Send + 'static,
NewResBody: HttpBody<Data = Bytes> + Send + 'static,
NewResBody::Error: Into<BoxError>,
{
let layer = ServiceBuilder::new()
.map_err(Into::into)
.layer(MapResponseBodyLayer::new(boxed))
.layer(layer)
.into_inner();