Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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