summaryrefslogtreecommitdiff
path: root/request_id.go
diff options
context:
space:
mode:
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 ""
}