TaylorCFrey commented on a change in pull request #5475:
URL: https://github.com/apache/trafficcontrol/pull/5475#discussion_r569832137
##########
File path: traffic_ops/traffic_ops_golang/crconfig/handler.go
##########
@@ -75,8 +77,17 @@ func SnapshotGetHandler(w http.ResponseWriter, r
*http.Request) {
api.HandleErr(w, r, inf.Tx.Tx, http.StatusNotFound,
errors.New("CDN not found"), nil)
return
}
- w.Header().Set(rfc.ContentType, rfc.ApplicationJSON)
- w.Write([]byte(`{"response":` + snapshot + `}`))
+
+ var decoded tc.CRConfig
+ if err = json.Unmarshal([]byte(snapshot), &decoded); err != nil {
+ api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError,
nil, fmt.Errorf("failed to unmarshal stored snapshot for cdn '%s': %v",
inf.Params["cdn"], err))
+ }
+
+ if inf.Version.Major < 4 {
+ decoded.Stats.TMPath = new(string)
+ *decoded.Stats.TMPath =
fmt.Sprintf("/api/4.0/cdns/%s/snapshot", inf.Params["cdn"])
+ }
+ api.WriteResp(w, r, decoded)
Review comment:
Sounds good.
----------------------------------------------------------------
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]