X-Request-Id Middleware
See original GitHub issueWe’ve got an internally used middleware, and wondering whether this would be useful to contribute back into http4s. The basic concept is, propagate the header from request to response, generating a random UUID X-Request-Id
if it wasn’t set.
Gist of the code (older version of http4s as can be seen by presence of .ci
): https://gist.github.com/Slakah/f5eb4fbe3c6cc1ed28f8bd66482cd566
Docs:
Does it also make sense to add official support for the header as well in the headers
package, i.e.
package org.http4s
package headers
object `X-Requested-With` extends HeaderKey.Default
Let me know if this is something you’ll be interested in, and I can draft a PR.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Request ID Middleware | Echo - High performance, minimalist ...
Request ID middleware for Echo | Echo is a high performance, extensible, ... You can set the id from the requester with the...
Read more >gin-contrib/requestid: Request ID middleware for Gin Framework
Request ID middleware for Gin Framework. Adds an indentifier to the response using the X-Request-ID header. Passes the X-Request-ID value back to the...
Read more >Logging with request ID in Go microservice | by X Li - Medium
The idea is very simple, just add the request ID to the http.Request in the first middleware. Then it can be used along...
Read more >express-request-id - npm
Generate UUID for request. Latest version: 3.0.0, last published: 2 months ago. Start using express-request-id in your project by running ...
Read more >RequestID - Fiber
RequestID. RequestID middleware for Fiber that adds an indentifier to the response. ... "github.com/gofiber/fiber/v2/middleware/requestid".
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We could punt and just use
UUID.randomUUID()
, which is improving since it traumatized me, and point people to fuid-http4s for something more customizable for people who run into performance problems.Or we could provide an alternate constructor that takes a
F[UUID]
, and make the default one requireSync[F]
to do anF.delay(UUID.randomUUID())
. Then people could fix their own contention point without a fuuid dependency, or use whatever fuuid provides.Or we could accept an
Eval[Random]
, with a defaultEval.now(new SecureRandom())
, and let people bring their own random strategy to the table. But that use ofEval
for pooling is shady.I think I like option 2.
Implemented by #3487