Add files via upload

This commit is contained in:
shray sharma 2024-10-06 10:28:36 +02:00 committed by GitHub
parent 1c4e265a70
commit 5a4f05c8ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 8 deletions

View File

@ -53,7 +53,7 @@ where
T: Transform<S, Req>, T: Transform<S, Req>,
T::Future: 'static, T::Future: 'static,
T::Response: MapServiceResponseBody, T::Response: MapServiceResponseBody,
T::Error: Into<Error>, T::Error: Into<Error> + std::fmt::Debug,
{ {
type Response = ServiceResponse<BoxBody>; type Response = ServiceResponse<BoxBody>;
type Error = Error; type Error = Error;
@ -63,10 +63,8 @@ where
fn new_transform(&self, service: S) -> Self::Future { fn new_transform(&self, service: S) -> Self::Future {
let fut = self.transform.new_transform(service); let fut = self.transform.new_transform(service);
Box::pin(async move {
let service = fut.await?; Box::pin(async move { fut.await.map(|service| CompatMiddleware { service }) })
Ok(CompatMiddleware { service })
})
} }
} }
@ -78,7 +76,7 @@ impl<S, Req> Service<Req> for CompatMiddleware<S>
where where
S: Service<Req>, S: Service<Req>,
S::Response: MapServiceResponseBody, S::Response: MapServiceResponseBody,
S::Error: Into<Error>, S::Error: Into<Error> + std::fmt::Debug,
{ {
type Response = ServiceResponse<BoxBody>; type Response = ServiceResponse<BoxBody>;
type Error = Error; type Error = Error;
@ -103,14 +101,17 @@ impl<Fut, T, E> Future for CompatMiddlewareFuture<Fut>
where where
Fut: Future<Output = Result<T, E>>, Fut: Future<Output = Result<T, E>>,
T: MapServiceResponseBody, T: MapServiceResponseBody,
E: Into<Error>, E: Into<Error> + std::fmt::Debug,
{ {
type Output = Result<ServiceResponse<BoxBody>, Error>; type Output = Result<ServiceResponse<BoxBody>, Error>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let res = match ready!(self.project().fut.poll(cx)) { let res = match ready!(self.project().fut.poll(cx)) {
Ok(res) => res, Ok(res) => res,
Err(err) => return Poll::Ready(Err(err.into())), Err(err) => {
log::error!("Request failed with error: {:?}", err); // for better visibility
return Poll::Ready(Err(err.into()));
}
}; };
Poll::Ready(Ok(res.map_body())) Poll::Ready(Ok(res.map_body()))