don't just overwrite the context metadata, append if already exists
This commit is contained in:
parent
bcff71167c
commit
4fa909a3c7
@ -18,5 +18,12 @@ func GetMetadata(ctx context.Context) (Metadata, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func WithMetadata(ctx context.Context, md Metadata) context.Context {
|
func WithMetadata(ctx context.Context, md Metadata) context.Context {
|
||||||
|
if emd, ok := ctx.Value(mdKey).(Metadata); ok {
|
||||||
|
for k, v := range emd {
|
||||||
|
if _, ok := md[k]; !ok {
|
||||||
|
md[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return context.WithValue(ctx, mdKey, md)
|
return context.WithValue(ctx, mdKey, md)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user