Skip to content

Commit

Permalink
Allow Error: Into<Infallible> for Route::{layer, route_layer} (#948)
Browse files Browse the repository at this point in the history
* Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}` (#924)

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

Fixes #922

* changelog

* fixup changelog
  • Loading branch information
davidpdrsn committed Jun 11, 2022
1 parent fed9a72 commit 9ec32a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions axum/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- **added:** Support resolving host name via `Forwarded` header in `Host`
extractor ([#1078])
- **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])

[#924]: https://github.com/tokio-rs/axum/pull/924
[#1078]: https://github.com/tokio-rs/axum/pull/1078
[#1077]: https://github.com/tokio-rs/axum/pull/1077

Expand Down
15 changes: 7 additions & 8 deletions axum/src/routing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,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();
Expand Down Expand Up @@ -332,15 +332,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();
Expand Down

0 comments on commit 9ec32a7

Please sign in to comment.