use crate::Service;
mod map_err;
mod map_response;
pub use self::{map_err::MapErr, map_response::MapResponse};
pub trait ServiceExt<Cx, Req>: Service<Cx, Req> + Sized {
fn map_err<E, F: FnOnce(Self::Error) -> E>(self, f: F) -> MapErr<Self, F>;
fn map_response<F: FnOnce(Self::Response) -> Response, Response>(
self,
f: F,
) -> MapResponse<Self, F>;
}
impl<T, Cx, Req> ServiceExt<Cx, Req> for T
where
T: Service<Cx, Req>,
{
fn map_err<E, F: FnOnce(Self::Error) -> E>(self, f: F) -> MapErr<Self, F> {
MapErr { inner: self, f }
}
fn map_response<F: FnOnce(Self::Response) -> Response, Response>(
self,
f: F,
) -> MapResponse<Self, F> {
MapResponse { inner: self, f }
}
}