You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2019/09/23 12:41:17 UTC

[GitHub] [trafficcontrol] mhoppa commented on a change in pull request #3932: Rewrote /user/login/token to Go

mhoppa commented on a change in pull request #3932: Rewrote /user/login/token to Go
URL: https://github.com/apache/trafficcontrol/pull/3932#discussion_r327089039
 
 

 ##########
 File path: traffic_ops/client/session.go
 ##########
 @@ -142,6 +156,29 @@ func (to *Session) login() (net.Addr, error) {
 	return remoteAddr, nil
 }
 
+func (to *Session) loginWithToken(token []byte) (net.Addr, error) {
+	path := apiBase + "/user/login/token"
+	resp, remoteAddr, err := to.rawRequest(http.MethodPost, path, token)
+	resp, remoteAddr, err = to.ErrUnlessOK(resp, remoteAddr, err, path)
+	if err != nil {
+		return remoteAddr, fmt.Errorf("requesting: %v", err)
+	}
+	defer resp.Body.Close()
+
+	var alerts tc.Alerts
+	if err := json.NewDecoder(resp.Body).Decode(&alerts); err != nil {
+		return remoteAddr, fmt.Errorf("decoding response JSON: %v", err)
+	}
+
+	for _, alert := range alerts.Alerts {
 
 Review comment:
   would checking 2xx be better then string match on the alerts?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services