aboutsummaryrefslogtreecommitdiff
path: root/weed/util
diff options
context:
space:
mode:
authorAleksey Kosov <rusyak777@list.ru>2025-05-21 17:57:39 +0300
committerGitHub <noreply@github.com>2025-05-21 07:57:39 -0700
commit5182d46e22d2458b16f1f2fb0358f6b5f3e18b5d (patch)
tree1f95adace7c8954512150f205005a347aff3653b /weed/util
parent140b7a7402109a55072458e42a32bc1ef4a608a9 (diff)
downloadseaweedfs-5182d46e22d2458b16f1f2fb0358f6b5f3e18b5d.tar.xz
seaweedfs-5182d46e22d2458b16f1f2fb0358f6b5f3e18b5d.zip
Added middleware for processing request_id grpc and http requests (#6805)
Diffstat (limited to 'weed/util')
-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)
+}