use new encoder, not marshalindent

This commit is contained in:
Fran Bull 2025-02-26 09:10:10 -08:00
parent 3a35ac716d
commit f7ec770f03

View File

@ -117,8 +117,13 @@ func (m *monitor) handleNetmap(w http.ResponseWriter, r *http.Request) {
http.Error(w, "", 500)
return
}
j, _ := json.MarshalIndent(n.NetMap, "", "\t")
w.Write([]byte(j))
encoder := json.NewEncoder(w)
encoder.SetIndent("", "\t")
if err := encoder.Encode(n); err != nil {
log.Printf("monitor: error encoding netmap: %v", err)
http.Error(w, "", http.StatusInternalServerError)
return
}
return
}