mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-25 00:00:23 +02:00
Fix ServiceExt::handle_error footgun (#120)
As described in https://github.com/tokio-rs/axum/pull/108#issuecomment-892811637, a `HandleError` created from `axum::ServiceExt::handle_error` should _not_ implement `RoutingDsl` as that leads to confusing routing behavior. The technique used here of adding another type parameter to `HandleError` isn't very clean, I think. But the alternative is duplicating `HandleError` and having two versions, which I think is less desirable.
This commit is contained in:
+2
-1
@@ -6,6 +6,7 @@ use crate::{
|
||||
buffer::MpscBuffer,
|
||||
extract::connect_info::{Connected, IntoMakeServiceWithConnectInfo},
|
||||
response::IntoResponse,
|
||||
service::HandleErrorFromRouter,
|
||||
util::ByteStr,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
@@ -716,7 +717,7 @@ impl<S> Layered<S> {
|
||||
pub fn handle_error<F, ReqBody, ResBody, Res, E>(
|
||||
self,
|
||||
f: F,
|
||||
) -> crate::service::HandleError<S, F, ReqBody>
|
||||
) -> crate::service::HandleError<S, F, ReqBody, HandleErrorFromRouter>
|
||||
where
|
||||
S: Service<Request<ReqBody>, Response = Response<ResBody>> + Clone,
|
||||
F: FnOnce(S::Error) -> Result<Res, E>,
|
||||
|
||||
Reference in New Issue
Block a user