Adds pretty print to info

This commit is contained in:
Alexey Khit
2022-09-16 17:35:41 +03:00
parent 105331d50f
commit 8f43ad2a35
2 changed files with 4 additions and 16 deletions
+3 -7
View File
@@ -102,13 +102,9 @@ func streamsHandler(w http.ResponseWriter, r *http.Request) {
v = streams.All() v = streams.All()
} }
data, err := json.Marshal(v) e := json.NewEncoder(w)
if err != nil { e.SetIndent("", " ")
log.Error().Err(err).Msg("[api.streams] marshal") _ = e.Encode(v)
return
}
_, _ = w.Write(data)
} }
func apiWS(w http.ResponseWriter, r *http.Request) { func apiWS(w http.ResponseWriter, r *http.Request) {
+1 -9
View File
@@ -54,15 +54,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) {
items = append(items, device) items = append(items, device)
} }
data, err := json.Marshal(items) _= json.NewEncoder(w).Encode(items)
if err != nil {
log.Error().Err(err).Msg("[api.homekit]")
return
}
if _, err = w.Write(data); err != nil {
log.Error().Err(err).Msg("[api.homekit]")
}
case "POST": case "POST":
// TODO: post params... // TODO: post params...