poem
poem copied to clipboard
How to access `operation_id` in middleware?
Hey, I have some logging middleware where I'd love to do log based on operation_id
, but I don't know how I can access that data from middleware. I can't see anything on request
or next
that lets me access this information about the endpoint.
Thanks!
I'll add it tomorrow.
When I thought about it, I found that this is not easy to achieve, the outer middleware cannot get the operation_id
. 😂
I see, I wonder if there is some way I can pass it in manually per route then into some middleware? Or get the function name of the handler instead?
Currently I'm using the path but that is a breaking change compared to our previous warp based method.
I've add an example to show how to get the operation-id
from the response.
https://github.com/poem-web/poem/tree/master/examples/openapi/log-with-operation-id
omg you're such a legend, thanks so much for this, looks like it'll work great. I'll try it out soon, probably on the next poem-openapi release to crates.io, or maybe before that if I get time. Thanks again!!
Used it here: https://github.com/aptos-labs/aptos-core/pull/2781! Still testing but looks good!