feat(request-id): Add request-id constructor#552
feat(request-id): Add request-id constructor#552tottoto wants to merge 1 commit intotower-rs:mainfrom
Conversation
f532cd1 to
6496831
Compare
| use tower_service::Service; | ||
| use uuid::Uuid; | ||
|
|
||
| pub(crate) const REQUEST_ID: HeaderName = HeaderName::from_static("x-request-id"); |
There was a problem hiding this comment.
This still has the x- 😄
But also, do you have a link to docs for the non-x--prefixed header?
There was a problem hiding this comment.
Fixed, and rebased to resolve the conflict.
There was a problem hiding this comment.
https://www.rfc-editor.org/rfc/rfc6648 deprecates "X-" prefix header, and request-id is also commonly used same as x-request-id.
There was a problem hiding this comment.
The RFC says "deprecates the convention for newly defined parameters" (emphasis mine) though. Do you have a source for the claim that it's commonly used?
b8e0d1b to
a9ef9e7
Compare
|
FWIW might want to add a unit test to also test the request_id one. It's dumb logic, but it's easy enough to copy one of the x-request-id ones :) |
originally contributed to tower-http by @tottoto in <tower-rs/tower-http#552> Co-authored-by: tottoto <tottotodev@gmail.com>
5f8b977 to
d8d79ce
Compare
There was a problem hiding this comment.
@tottoto I didn't see a lot of public usage. A smattering of larger clients (stripe, microsoft stuff, etc). But nothing reaching the point of convention.
Would be happy to accept a doc change to show the full custom header usage:
const REQUEST_ID: HeaderName = HeaderName::from_static("request-id");
let svc = ServiceBuilder::new()
.set_request_id(REQUEST_ID, MyMakeRequestId::default())
.propagate_request_id(REQUEST_ID)
.service(handler);
It also might nice to offer a cleaner helper...
let svc = ServiceBuilder::new()
.emit_request_id("request-id", MyMakeRequestId::default())
.service(handler);
Motivation
Provides the same constructor of request-id as x-request-id.
Solution
Adds request-id constructor.