Skip to content

Commit

Permalink
api: use http request Clone (micro#1458)
Browse files Browse the repository at this point in the history
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
  • Loading branch information
vtolstov committed Mar 31, 2020
1 parent 8a8742f commit 7b7a859
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions api/handler/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (h *rpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
cx = metadata.MergeContext(cx, md, true)

// set merged context to request
*r = *r.WithContext(cx)
*r = *r.Clone(cx)

// if stream we currently only support json
if isStream(r, service) {
Expand Down Expand Up @@ -324,7 +324,7 @@ func requestPayload(r *http.Request) ([]byte, error) {
}

// restore context without fields
*r = *r.WithContext(metadata.NewContext(ctx, md))
*r = *r.Clone(metadata.NewContext(ctx, md))

for k, v := range matches {
ps := strings.Split(k, ".")
Expand Down
2 changes: 1 addition & 1 deletion api/router/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (r *staticRouter) endpoint(req *http.Request) (*endpoint, error) {
for k, v := range matches {
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
}
if !pMatch {
Expand Down

0 comments on commit 7b7a859

Please sign in to comment.