diff options
| author | Aleksey Kosov <rusyak777@list.ru> | 2025-05-21 17:57:39 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-21 07:57:39 -0700 |
| commit | 5182d46e22d2458b16f1f2fb0358f6b5f3e18b5d (patch) | |
| tree | 1f95adace7c8954512150f205005a347aff3653b /weed/util | |
| parent | 140b7a7402109a55072458e42a32bc1ef4a608a9 (diff) | |
| download | seaweedfs-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.go | 20 |
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) +} |
