Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestId Middleware #806

Merged
merged 3 commits into from
May 11, 2024
Merged

RequestId Middleware #806

merged 3 commits into from
May 11, 2024

Conversation

vbrandl
Copy link
Contributor

@vbrandl vbrandl commented Apr 26, 2024

This PR introduces a feature-gated RequestId middleware that associates an unique ID with each incoming request. ReqId can be extracted in request handlers and returned as a response (e.g. for error pages). Each response contains a header with the ID (default name: x-request-id but the header name is configurable).

The Tracing middleware was made aware of the request ID and adds it to the request span (for this to work, the order of the middlewares is important. Tracing must be applied before RequestId.

If ReuseId::Use is set, the middleware will propagate the request ID from an incoming request. If the request contained an x-request-id header (or whatever header name is configured), this value will be used.

@sunli829 sunli829 merged commit 7aa5a12 into poem-web:master May 11, 2024
0 of 7 checks passed
@sunli829
Copy link
Collaborator

thanks 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants