Skip to content

Commit 2c63486

Browse files
committedNov 27, 2020
added a copy method for ease of copying the request ID from one context to another
1 parent bf73b1f commit 2c63486

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎context.go

+13
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,16 @@ func Get(ctx context.Context) (requestID string, err error) {
4141

4242
return
4343
}
44+
45+
// Copy gets the requestID from the source context, and copies it over
46+
// to the target context.
47+
func Copy(source context.Context, target *context.Context) error {
48+
requestID, err := Get(source)
49+
if err != nil {
50+
return err
51+
}
52+
53+
*target = Set(*target, requestID)
54+
55+
return nil
56+
}

0 commit comments

Comments
 (0)
Please sign in to comment.