rawlinp closed pull request #3098: Fix Traffic Ops Golang wrapper copying
*http.Request, breaking status codes
URL: https://github.com/apache/trafficcontrol/pull/3098
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/traffic_ops/traffic_ops_golang/api/api.go
b/traffic_ops/traffic_ops_golang/api/api.go
index 5143828a0..d1ec4f29f 100644
--- a/traffic_ops/traffic_ops_golang/api/api.go
+++ b/traffic_ops/traffic_ops_golang/api/api.go
@@ -526,8 +526,8 @@ func GetUserFromReq(w http.ResponseWriter, r *http.Request,
secret string) (auth
return user, nil, nil, http.StatusOK
}
-func AddUserToReq(r *http.Request, u auth.CurrentUser) *http.Request {
+func AddUserToReq(r *http.Request, u auth.CurrentUser) {
ctx := r.Context()
ctx = context.WithValue(ctx, auth.CurrentUserKey, u)
- return r.WithContext(ctx)
+ *r = *r.WithContext(ctx)
}
diff --git a/traffic_ops/traffic_ops_golang/wrappers.go
b/traffic_ops/traffic_ops_golang/wrappers.go
index e30a35c04..b06fd5bd0 100644
--- a/traffic_ops/traffic_ops_golang/wrappers.go
+++ b/traffic_ops/traffic_ops_golang/wrappers.go
@@ -63,7 +63,7 @@ func (a AuthBase) GetWrapper(privLevelRequired int)
Middleware {
if user.PrivLevel < privLevelRequired {
api.HandleErr(w, r, nil, http.StatusForbidden,
errors.New("Forbidden."), nil)
}
- r = api.AddUserToReq(r, user)
+ api.AddUserToReq(r, user)
handlerFunc(w, r)
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services