use gofrs uuid

This commit is contained in:
2025-05-16 10:40:20 -04:00
parent af4b0190d0
commit b4b634fd3f
3 changed files with 7 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ import (
"log/slog"
"net/http"
"github.com/google/uuid"
"github.com/gofrs/uuid/v5"
)
type contextKey string
@@ -14,7 +14,10 @@ const TraceIdKey contextKey = "trace_id"
func ContextMiddleware(logger *slog.Logger) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
traceid := uuid.NewString()
traceid, err := uuid.NewV4()
if err != nil {
logger.ErrorContext(r.Context(), err.Error())
}
ctx := context.WithValue(r.Context(), TraceIdKey, traceid)
newReq := r.WithContext(ctx)