diff options
| author | Aleksey Kosov <rusyak777@list.ru> | 2025-05-28 21:34:02 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-28 11:34:02 -0700 |
| commit | 283d9e0079d5deb57aefe9a7b30e8b9869ba8685 (patch) | |
| tree | 87b09bebed2ee4afc9c2a4f711ac8598fe2949b7 /weed/util/request_id.go | |
| parent | 62aaaa18f3ea8b7600d28934580dc220ca95164a (diff) | |
| download | seaweedfs-283d9e0079d5deb57aefe9a7b30e8b9869ba8685.tar.xz seaweedfs-283d9e0079d5deb57aefe9a7b30e8b9869ba8685.zip | |
Add context with request (#6824)
Diffstat (limited to 'weed/util/request_id.go')
| -rw-r--r-- | weed/util/request_id.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/weed/util/request_id.go b/weed/util/request_id.go index 85ec254dc..7945e7cc4 100644 --- a/weed/util/request_id.go +++ b/weed/util/request_id.go @@ -1,6 +1,9 @@ package util -import "context" +import ( + "context" + "net/http" +) const ( RequestIdHttpHeader = "X-Request-ID" @@ -18,3 +21,7 @@ func GetRequestID(ctx context.Context) string { func WithRequestID(ctx context.Context, id string) context.Context { return context.WithValue(ctx, RequestIDKey, id) } + +func ReqWithRequestId(req *http.Request, ctx context.Context) { + req.Header.Set(RequestIdHttpHeader, GetRequestID(ctx)) +} |
