api: use http request Clone (#1458)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-04-01 01:50:37 +03:00 committed by GitHub
parent 8a8742f867
commit 7b7a859a03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -128,7 +128,7 @@ func (h *rpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
cx = metadata.MergeContext(cx, md, true) cx = metadata.MergeContext(cx, md, true)
// set merged context to request // set merged context to request
*r = *r.WithContext(cx) *r = *r.Clone(cx)
// if stream we currently only support json // if stream we currently only support json
if isStream(r, service) { if isStream(r, service) {
@ -324,7 +324,7 @@ func requestPayload(r *http.Request) ([]byte, error) {
} }
// restore context without fields // restore context without fields
*r = *r.WithContext(metadata.NewContext(ctx, md)) *r = *r.Clone(metadata.NewContext(ctx, md))
for k, v := range matches { for k, v := range matches {
ps := strings.Split(k, ".") ps := strings.Split(k, ".")

View File

@ -262,7 +262,7 @@ func (r *staticRouter) endpoint(req *http.Request) (*endpoint, error) {
for k, v := range matches { for k, v := range matches {
md[fmt.Sprintf("x-api-field-%s", k)] = v md[fmt.Sprintf("x-api-field-%s", k)] = v
} }
*req = *req.WithContext(context.WithValue(ctx, metadata.MetadataKey{}, md)) *req = *req.Clone(context.WithValue(ctx, metadata.MetadataKey{}, md))
break pathLoop break pathLoop
} }
if !pMatch { if !pMatch {