Strip MetadataKey global var

This commit is contained in:
Asim Aslam 2020-04-12 11:16:08 +01:00 committed by Vasiliy Tolstov
parent 5e650deb07
commit a26b37aaf9

4
rpc.go
View File

@ -118,7 +118,7 @@ func (h *rpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// create context // create context
cx := ctx.FromRequest(r) cx := ctx.FromRequest(r)
// get context from http handler wrappers // get context from http handler wrappers
md, ok := r.Context().Value(metadata.MetadataKey{}).(metadata.Metadata) md, ok := metadata.FromContext(r.Context())
if !ok { if !ok {
md = make(metadata.Metadata) md = make(metadata.Metadata)
} }
@ -293,7 +293,7 @@ func requestPayload(r *http.Request) ([]byte, error) {
// otherwise as per usual // otherwise as per usual
ctx := r.Context() ctx := r.Context()
// dont user meadata.FromContext as it mangles names // dont user meadata.FromContext as it mangles names
md, ok := ctx.Value(metadata.MetadataKey{}).(metadata.Metadata) md, ok := metadata.FromContext(ctx)
if !ok { if !ok {
md = make(map[string]string) md = make(map[string]string)
} }