rob05c commented on a change in pull request #2653: Fix TO Go routes to all use 
transactions and timeouts
URL: https://github.com/apache/trafficcontrol/pull/2653#discussion_r209756497
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/monitoring/monitoring.go
 ##########
 @@ -110,56 +86,70 @@ type Monitoring struct {
        Config           map[string]interface{} `json:"config"`
 }
 
-// MonitoringResponse ...
 type MonitoringResponse struct {
        Response Monitoring `json:"response"`
 }
 
-// Router ...
 type Router struct {
        Type    string
        Profile string
 }
 
-// DeliveryService ...
 type DeliveryService struct {
        XMLID              string  `json:"xmlId"`
        TotalTPSThreshold  float64 `json:"totalTpsThreshold"`
        Status             string  `json:"status"`
        TotalKBPSThreshold float64 `json:"totalKbpsThreshold"`
 }
 
-// TODO change to use the PathParams, instead of parsing the URL
-func monitoringHandler(db *sqlx.DB) http.HandlerFunc {
-       return func(w http.ResponseWriter, r *http.Request) {
-               handleErrs := tc.GetHandleErrorsFunc(w, r)
+func Get(w http.ResponseWriter, r *http.Request) {
+       inf, userErr, sysErr, errCode := api.NewInfo(r, []string{"cdn"}, nil)
+       if userErr != nil || sysErr != nil {
+               api.HandleErr(w, r, errCode, userErr, sysErr)
+               return
+       }
+       defer inf.Close()
+       *inf.CommitTx = true
+       api.RespWriter(w, r)(getMonitoringJSON(inf.Tx.Tx, inf.Params["cdn"]))
 
 Review comment:
   As below, `RespWriter` -> `WriteResp` -> `WriteRespRaw` -> 
`w.Header().Set("Content-Type"` 
   
   
https://github.com/apache/trafficcontrol/blob/master/traffic_ops/traffic_ops_golang/api/api.go#L67

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


With regards,
Apache Git Services

Reply via email to