dont overwrite metadata

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-05-05 16:39:41 +03:00
parent 6dbd6e27e4
commit 4cb50e8692

View File

@ -19,12 +19,12 @@ var (
// MetadataFunc wil be used if user not provide own func to fill metadata // MetadataFunc wil be used if user not provide own func to fill metadata
MetadataFunc = func(ctx context.Context) (context.Context, error) { MetadataFunc = func(ctx context.Context) (context.Context, error) {
md, ok := metadata.FromIncomingContext(ctx) md, ok := metadata.FromIncomingContext(ctx)
if ok { if !ok {
if _, ok = md.Get(MetadataKey); ok { md = metadata.New(1)
return ctx, nil }
} if _, ok = md.Get(MetadataKey); ok {
return ctx, nil
} }
md = metadata.New(1)
id, err := uuid.NewRandom() id, err := uuid.NewRandom()
if err != nil { if err != nil {
return ctx, err return ctx, err