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()
}
data, err := json.Marshal(v)
if err != nil {
log.Error().Err(err).Msg("[api.streams] marshal")
return
}
_, _ = w.Write(data)
e := json.NewEncoder(w)
e.SetIndent("", " ")
_ = e.Encode(v)
}
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)
}
data, err := json.Marshal(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]")
}
_= json.NewEncoder(w).Encode(items)
case "POST":
// TODO: post params...