ocket8888 commented on a change in pull request #4196: TP: Provides the ability 
to view all users for a given role
URL: https://github.com/apache/trafficcontrol/pull/4196#discussion_r375974573
 
 

 ##########
 File path: traffic_ops/client/user.go
 ##########
 @@ -36,8 +37,26 @@ func (to *Session) Users() ([]tc.User, error) {
 
 // GetUsers returns all users accessible from current user
 func (to *Session) GetUsers() ([]tc.User, ReqInf, error) {
-       route := apiBase + "/users.json"
-       resp, remoteAddr, err := to.request("GET", route, nil)
+       route := apiBase + "/users"
+       resp, remoteAddr, err := to.request(http.MethodGet, route, nil)
+       reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: 
remoteAddr}
+       if err != nil {
+               return nil, reqInf, err
+       }
+       defer resp.Body.Close()
+
+       var data tc.UsersResponse
+       if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
+               return nil, reqInf, err
+       }
+
+       return data.Response, reqInf, nil
 
 Review comment:
   well you don't need to rewrite `GetUsers` if you don't want to. Git diffs 
are weird, I put this in the part it said you changed but it looks like what 
you actually did was remove `.json` and add the `GetUsersByRole` method, so 
really it just ought to be changed in `GetUsersByRole`. Though I'd consider the 
same change to `GetUsers` an improvement and encourage you to do that too, if 
you want.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

Reply via email to