question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

X-Request-Id Middleware

See original GitHub issue

We’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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rossabakercommented, Jun 10, 2020
  1. 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.

  2. Or we could provide an alternate constructor that takes a F[UUID], and make the default one require Sync[F] to do an F.delay(UUID.randomUUID()). Then people could fix their own contention point without a fuuid dependency, or use whatever fuuid provides.

  3. Or we could accept an Eval[Random], with a default Eval.now(new SecureRandom()), and let people bring their own random strategy to the table. But that use of Eval for pooling is shady.

I think I like option 2.

0reactions
Slakahcommented, Jun 20, 2020

Implemented by #3487

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found