Skip to content

Commit

Permalink
Default to generating request IDs using UUIDv4 format in CA
Browse files Browse the repository at this point in the history
  • Loading branch information
hslatman committed Mar 1, 2024
1 parent 0898c6d commit 7fd524f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/requestid/requestid.go
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"

"github.com/rs/xid"
"go.step.sm/crypto/randutil"
)

const (
Expand Down Expand Up @@ -61,9 +62,16 @@ func (h *Handler) Middleware(next http.Handler) http.Handler {
return http.HandlerFunc(fn)
}

// newRequestID creates a new request ID using github.com/rs/xid.
// newRequestID generates a new random UUIDv4 request ID. If UUIDv4
// generation fails, it'll fallback to generating a random ID using
// github.com/rs/xid.
func newRequestID() string {
return xid.New().String()
requestID, err := randutil.UUIDv4()
if err != nil {
requestID = xid.New().String()
}

return requestID
}

type requestIDKey struct{}
Expand Down

0 comments on commit 7fd524f

Please sign in to comment.