mirror of
https://github.com/tokio-rs/axum.git
synced 2025-01-05 02:22:03 +01:00
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
This commit is contained in:
parent
afcefb4a70
commit
ca7ecb159b
2 changed files with 9 additions and 8 deletions
|
@ -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 `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
|
- **added:** Add `axum::extract::multipart::Field::chunk` method for streaming a single chunk from
|
||||||
the field ([#901])
|
the field ([#901])
|
||||||
|
- **changed:** Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}` ([#924])
|
||||||
- **fixed:** Fix trailing slash redirection with query parameters ([#936])
|
- **fixed:** Fix trailing slash redirection with query parameters ([#936])
|
||||||
|
|
||||||
[#901]: https://github.com/tokio-rs/axum/pull/901
|
[#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
|
[#927]: https://github.com/tokio-rs/axum/pull/927
|
||||||
[#936]: https://github.com/tokio-rs/axum/pull/936
|
[#936]: https://github.com/tokio-rs/axum/pull/936
|
||||||
|
|
||||||
|
|
|
@ -291,15 +291,15 @@ where
|
||||||
pub fn layer<L, NewReqBody, NewResBody>(self, layer: L) -> Router<NewReqBody>
|
pub fn layer<L, NewReqBody, NewResBody>(self, layer: L) -> Router<NewReqBody>
|
||||||
where
|
where
|
||||||
L: Layer<Route<B>>,
|
L: Layer<Route<B>>,
|
||||||
L::Service: Service<Request<NewReqBody>, Response = Response<NewResBody>, Error = Infallible>
|
L::Service:
|
||||||
+ Clone
|
Service<Request<NewReqBody>, Response = Response<NewResBody>> + Clone + Send + 'static,
|
||||||
+ Send
|
<L::Service as Service<Request<NewReqBody>>>::Error: Into<Infallible> + 'static,
|
||||||
+ 'static,
|
|
||||||
<L::Service as Service<Request<NewReqBody>>>::Future: Send + 'static,
|
<L::Service as Service<Request<NewReqBody>>>::Future: Send + 'static,
|
||||||
NewResBody: HttpBody<Data = Bytes> + Send + 'static,
|
NewResBody: HttpBody<Data = Bytes> + Send + 'static,
|
||||||
NewResBody::Error: Into<BoxError>,
|
NewResBody::Error: Into<BoxError>,
|
||||||
{
|
{
|
||||||
let layer = ServiceBuilder::new()
|
let layer = ServiceBuilder::new()
|
||||||
|
.map_err(Into::into)
|
||||||
.layer(MapResponseBodyLayer::new(boxed))
|
.layer(MapResponseBodyLayer::new(boxed))
|
||||||
.layer(layer)
|
.layer(layer)
|
||||||
.into_inner();
|
.into_inner();
|
||||||
|
@ -332,15 +332,14 @@ where
|
||||||
pub fn route_layer<L, NewResBody>(self, layer: L) -> Self
|
pub fn route_layer<L, NewResBody>(self, layer: L) -> Self
|
||||||
where
|
where
|
||||||
L: Layer<Route<B>>,
|
L: Layer<Route<B>>,
|
||||||
L::Service: Service<Request<B>, Response = Response<NewResBody>, Error = Infallible>
|
L::Service: Service<Request<B>, Response = Response<NewResBody>> + Clone + Send + 'static,
|
||||||
+ Clone
|
<L::Service as Service<Request<B>>>::Error: Into<Infallible> + 'static,
|
||||||
+ Send
|
|
||||||
+ 'static,
|
|
||||||
<L::Service as Service<Request<B>>>::Future: Send + 'static,
|
<L::Service as Service<Request<B>>>::Future: Send + 'static,
|
||||||
NewResBody: HttpBody<Data = Bytes> + Send + 'static,
|
NewResBody: HttpBody<Data = Bytes> + Send + 'static,
|
||||||
NewResBody::Error: Into<BoxError>,
|
NewResBody::Error: Into<BoxError>,
|
||||||
{
|
{
|
||||||
let layer = ServiceBuilder::new()
|
let layer = ServiceBuilder::new()
|
||||||
|
.map_err(Into::into)
|
||||||
.layer(MapResponseBodyLayer::new(boxed))
|
.layer(MapResponseBodyLayer::new(boxed))
|
||||||
.layer(layer)
|
.layer(layer)
|
||||||
.into_inner();
|
.into_inner();
|
||||||
|
|
Loading…
Reference in a new issue