From 4fa909a3c78bed66da7a22a79851896c69ac3e43 Mon Sep 17 00:00:00 2001 From: Asim Date: Thu, 26 Nov 2015 20:35:50 +0000 Subject: [PATCH] don't just overwrite the context metadata, append if already exists --- context/context.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/context/context.go b/context/context.go index 8906eb00..b7c8ab93 100644 --- a/context/context.go +++ b/context/context.go @@ -18,5 +18,12 @@ func GetMetadata(ctx context.Context) (Metadata, bool) { } 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) }