Signature of the on_response closure #431
-
The documents about trace layer gives the following example: .on_response(|response: &Response<Body>, latency: Duration, _span: &Span| {
tracing::debug!("response generated in {:?}", latency)
}) This will generate a error
And could run if change to .on_response(|response: &Response<http_body::combinators::UnsyncBoxBody<axum::body::Bytes, axum::Error>>, latency: Duration, _span: &Span| {
//something
}); I wonder if there is a feature that make these two types compatible. Also, is there a way to get the method and uri in the on_ response closure? |
Beta Was this translation helpful? Give feedback.
Answered by
davidpdrsn
Oct 29, 2023
Replies: 1 comment
-
The type of the response body is dictated by the service, not the middleware. Looks like you’re using axum which uses that response body type. You can just use the type that makes it compile. axum provides a type alias at |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
zrll12
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The type of the response body is dictated by the service, not the middleware. Looks like you’re using axum which uses that response body type.
You can just use the type that makes it compile. axum provides a type alias at
axum::body::BoxBody