summaryrefslogtreecommitdiff
path: root/request_id.go
diff options
context:
space:
mode:
authorAlexander NeonXP Kiryukhin <i@neonxp.ru>2024-07-28 19:32:33 +0300
committerAlexander NeonXP Kiryukhin <i@neonxp.ru>2024-07-28 19:32:33 +0300
commit18a9096684ab0b1468a08d442d38b7b675d94810 (patch)
tree16e335e56ac0bf7986c3fbcd924f2ac0e00106f8 /request_id.go
parent25160ef84704c0f4ef6e8c6cf2e282e216701139 (diff)
Session middlewareHEADmaster
Diffstat (limited to 'request_id.go')
-rw-r--r--request_id.go11
1 files changed, 3 insertions, 8 deletions
diff --git a/request_id.go b/request_id.go
index 0e9a521..016b44a 100644
--- a/request_id.go
+++ b/request_id.go
@@ -7,12 +7,7 @@ import (
"go.neonxp.ru/objectid"
)
-type ctxKeyRequestID int
-
-const (
- RequestIDKey ctxKeyRequestID = 0
- RequestIDHeader string = "X-Request-ID"
-)
+const RequestIDHeader string = "X-Request-ID"
func RequestID(next http.Handler) http.Handler {
objectid.Seed()
@@ -22,12 +17,12 @@ func RequestID(next http.Handler) http.Handler {
requestID = objectid.New().String()
}
- next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), RequestIDKey, requestID)))
+ next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), requestIDKey, requestID)))
})
}
func GetRequestID(r *http.Request) string {
- rid := r.Context().Value(RequestIDKey)
+ rid := r.Context().Value(requestIDKey)
if rid == nil {
return ""
}