aboutsummaryrefslogtreecommitdiff
path: root/weed/util/request_id.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/util/request_id.go')
-rw-r--r--weed/util/request_id.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/weed/util/request_id.go b/weed/util/request_id.go
new file mode 100644
index 000000000..85ec254dc
--- /dev/null
+++ b/weed/util/request_id.go
@@ -0,0 +1,20 @@
+package util
+
+import "context"
+
+const (
+ RequestIdHttpHeader = "X-Request-ID"
+ RequestIDKey = "x-request-id"
+)
+
+func GetRequestID(ctx context.Context) string {
+ if ctx == nil {
+ return ""
+ }
+ id, _ := ctx.Value(RequestIDKey).(string)
+ return id
+}
+
+func WithRequestID(ctx context.Context, id string) context.Context {
+ return context.WithValue(ctx, RequestIDKey, id)
+}