Skip to content

Commit

Permalink
Fix request ID middleware
Browse files Browse the repository at this point in the history
Signed-off-by: Douglas Camata <[email protected]>
  • Loading branch information
douglascamata committed Jan 11, 2024
1 parent ead8120 commit af890dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/server/http/middleware/request_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func RequestID(h http.Handler) http.HandlerFunc {
reqID := r.Header.Get("X-Request-ID")
if reqID == "" {
entropy := ulid.Monotonic(rand.New(rand.NewSource(time.Now().UnixNano())), 0)
reqID := ulid.MustNew(ulid.Timestamp(time.Now()), entropy)
r.Header.Set("X-Request-ID", reqID.String())
reqID = ulid.MustNew(ulid.Timestamp(time.Now()), entropy).String()
r.Header.Set("X-Request-ID", reqID)
}
ctx := newContextWithRequestID(r.Context(), reqID)
h.ServeHTTP(w, r.WithContext(ctx))
Expand Down

0 comments on commit af890dc

Please sign in to comment.