From 25160ef84704c0f4ef6e8c6cf2e282e216701139 Mon Sep 17 00:00:00 2001 From: Alexander NeonXP Kiryukhin Date: Sun, 28 Apr 2024 00:32:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D0=B2=D0=BD?= =?UTF-8?q?=D0=B5=D1=88=D0=BD=D1=8E=D1=8E=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81?= =?UTF-8?q?=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 5 +---- go.sum | 6 ++---- request_id.go | 5 +++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 30278e9..3c4be2d 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,4 @@ module go.neonxp.ru/middleware go 1.22.1 -require ( - github.com/google/uuid v1.6.0 - golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 -) +require go.neonxp.ru/objectid v0.0.2 diff --git a/go.sum b/go.sum index 1e212a5..3ce48c1 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,2 @@ -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 h1:985EYyeCOxTpcgOTJpflJUwOeEz0CQOdPt73OzpE9F8= -golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= +go.neonxp.ru/objectid v0.0.2 h1:Z/G6zvBxmUq0NTq681oGH8pTbBWwi6VA22YOYludIPs= +go.neonxp.ru/objectid v0.0.2/go.mod h1:s0dRi//oe1liiKcor1KmWx09WzkD6Wtww8ZaIv+VLBs= diff --git a/request_id.go b/request_id.go index b3650ef..0e9a521 100644 --- a/request_id.go +++ b/request_id.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "github.com/google/uuid" + "go.neonxp.ru/objectid" ) type ctxKeyRequestID int @@ -15,10 +15,11 @@ const ( ) func RequestID(next http.Handler) http.Handler { + objectid.Seed() return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { requestID := r.Header.Get(RequestIDHeader) if requestID == "" { - requestID = uuid.NewString() + requestID = objectid.New().String() } next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), RequestIDKey, requestID)))