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.go9
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))
+}