Skip to content

Commit 5646264

Browse files
committed
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 #922 * changelog * fixup changelog
1 parent af3bd79 commit 5646264

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

axum/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
extractor ([#1078])
1212
- **added:** Implement `IntoResponse` for `Form` ([#1095])
1313
- **change:** axum's MSRV is now 1.56 ([#1098])
14+
- **breaking:** Remove `extractor_middleware` which was previously deprecated.
15+
Use `axum::middleware::from_extractor` instead ([#1077])
16+
- **breaking:** Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}` ([#924])
1417
- **breaking:** Remove `extractor_middleware` which was previously deprecated.
1518
Use `axum::middleware::from_extractor` instead ([#1077])
1619

1720
[#1077]: https://github.com/tokio-rs/axum/pull/1077
1821
[#1078]: https://github.com/tokio-rs/axum/pull/1078
1922
[#1078]: https://github.com/tokio-rs/axum/pull/1078
23+
[#1078]: https://github.com/tokio-rs/axum/pull/1078
2024
[#1095]: https://github.com/tokio-rs/axum/pull/1095
2125
[#1098]: https://github.com/tokio-rs/axum/pull/1098
26+
[#924]: https://github.com/tokio-rs/axum/pull/924
2227

2328
# 0.5.7 (08. June, 2022)
2429

axum/src/routing/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,15 @@ where
291291
pub fn layer<L, NewReqBody, NewResBody>(self, layer: L) -> Router<NewReqBody>
292292
where
293293
L: Layer<Route<B>>,
294-
L::Service: Service<Request<NewReqBody>, Response = Response<NewResBody>, Error = Infallible>
295-
+ Clone
296-
+ Send
297-
+ 'static,
294+
L::Service:
295+
Service<Request<NewReqBody>, Response = Response<NewResBody>> + Clone + Send + 'static,
296+
<L::Service as Service<Request<NewReqBody>>>::Error: Into<Infallible> + 'static,
298297
<L::Service as Service<Request<NewReqBody>>>::Future: Send + 'static,
299298
NewResBody: HttpBody<Data = Bytes> + Send + 'static,
300299
NewResBody::Error: Into<BoxError>,
301300
{
302301
let layer = ServiceBuilder::new()
302+
.map_err(Into::into)
303303
.layer(MapResponseBodyLayer::new(boxed))
304304
.layer(layer)
305305
.into_inner();
@@ -332,15 +332,14 @@ where
332332
pub fn route_layer<L, NewResBody>(self, layer: L) -> Self
333333
where
334334
L: Layer<Route<B>>,
335-
L::Service: Service<Request<B>, Response = Response<NewResBody>, Error = Infallible>
336-
+ Clone
337-
+ Send
338-
+ 'static,
335+
L::Service: Service<Request<B>, Response = Response<NewResBody>> + Clone + Send + 'static,
336+
<L::Service as Service<Request<B>>>::Error: Into<Infallible> + 'static,
339337
<L::Service as Service<Request<B>>>::Future: Send + 'static,
340338
NewResBody: HttpBody<Data = Bytes> + Send + 'static,
341339
NewResBody::Error: Into<BoxError>,
342340
{
343341
let layer = ServiceBuilder::new()
342+
.map_err(Into::into)
344343
.layer(MapResponseBodyLayer::new(boxed))
345344
.layer(layer)
346345
.into_inner();

0 commit comments

Comments
 (0)