From e2c1df3de6fbc534596c94bf68092c7dd1917873 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sun, 12 Apr 2020 11:16:08 +0100 Subject: [PATCH] Strip MetadataKey global var --- static.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static.go b/static.go index 0c659c3..2b0218f 100644 --- a/static.go +++ b/static.go @@ -271,7 +271,7 @@ func (r *staticRouter) endpoint(req *http.Request) (*endpoint, error) { } pMatch = true ctx := req.Context() - md, ok := ctx.Value(metadata.MetadataKey{}).(metadata.Metadata) + md, ok := metadata.FromContext(ctx) if !ok { md = make(metadata.Metadata) } @@ -279,7 +279,7 @@ func (r *staticRouter) endpoint(req *http.Request) (*endpoint, error) { md[fmt.Sprintf("x-api-field-%s", k)] = v } md["x-api-body"] = ep.apiep.Body - *req = *req.Clone(context.WithValue(ctx, metadata.MetadataKey{}, md)) + *req = *req.Clone(metadata.NewContext(ctx, md)) break pathLoop } if !pMatch {