use crate::{async_trait, Handler, IntoResponse, Response, Result};
#[derive(Debug, Clone)]
pub struct MapInToResponse<H>(pub(crate) H);
impl<H> MapInToResponse<H> {
#[inline]
pub(super) fn new(h: H) -> Self {
Self(h)
}
}
#[async_trait]
impl<H, I, O> Handler<I> for MapInToResponse<H>
where
I: Send + 'static,
H: Handler<I, Output = Result<O>> + Clone,
O: IntoResponse + Send,
{
type Output = Result<Response>;
async fn call(&self, i: I) -> Self::Output {
self.0.call(i).await.map(IntoResponse::into_response)
}
}