How to inspect the absolutely final response? #252
-
When I use a middleware like so: impl<S, ReqBody, ResBody> Service<Request<ReqBody>> for MyMiddleware<S>
where
S: Service<Request<ReqBody>, Response = Response<ResBody>> + Clone + Send + 'static,
S::Future: Send + 'static,
ReqBody: Send + 'static,
ResBody: Send + 'static,
{
type Response = S::Response;
type Error = S::Error;
type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.inner.poll_ready(cx)
}
fn call(&mut self, mut req: Request<ReqBody>) -> Self::Future {
let clone = self.inner.clone();
let mut inner = std::mem::replace(&mut self.inner, clone);
Box::pin(async move {
let res: Response<ResBody> = inner.call(req).await?;
dbg!(res.headers());
Ok(res)
})
}
} The dbg!() will show:
However, a
How can I get the absolutely final request data (read-only is fine) before the request is sent out to the client? To be clear: For informational purposes my tool needs to show exactly which headers are about to be sent just as that happens. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I'm actually not sure that's possible 🤔 It is hyper that is tampering with the request before sending it. I would recommend you ask in hypers discord channel |
Beta Was this translation helpful? Give feedback.
I'm actually not sure that's possible 🤔 It is hyper that is tampering with the request before sending it. I would recommend you ask in hypers discord channel