Strip MetadataKey global var

This commit is contained in:
Asim Aslam 2020-04-12 11:16:08 +01:00 committed by Vasiliy Tolstov
parent 09caac9a80
commit e2c1df3de6

View File

@ -271,7 +271,7 @@ func (r *staticRouter) endpoint(req *http.Request) (*endpoint, error) {
} }
pMatch = true pMatch = true
ctx := req.Context() ctx := req.Context()
md, ok := ctx.Value(metadata.MetadataKey{}).(metadata.Metadata) md, ok := metadata.FromContext(ctx)
if !ok { if !ok {
md = make(metadata.Metadata) 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[fmt.Sprintf("x-api-field-%s", k)] = v
} }
md["x-api-body"] = ep.apiep.Body 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 break pathLoop
} }
if !pMatch { if !pMatch {