diff options
author | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-09-26 13:12:37 +0100 |
---|---|---|
committer | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-09-26 13:12:37 +0100 |
commit | 267c89fe42050d056b8c041ee66008e304c0bcf3 (patch) | |
tree | db3d519226bc8c58e3bd47196c6ae1fc25e0ca84 /handlers.go | |
parent | e13c16a261b71b7e590dda6c9ef826385b7b5b02 (diff) |
Diffstat (limited to 'handlers.go')
-rw-r--r-- | handlers.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/handlers.go b/handlers.go index 99ef718..227251b 100644 --- a/handlers.go +++ b/handlers.go @@ -32,13 +32,16 @@ func CacheIndex(w http.ResponseWriter, r *http.Request) { apicaches = append(apicaches, DBToAPI(dbcaches[db])) } - if err := json.NewEncoder(w).Encode(apicaches); err != nil { + out, err := json.MarshalIndent(apicaches, "", " ") + if err != nil { panic(err) } + + fmt.Fprintf(w, string(out)) } func MarshalCache(apicache APICache) (string, error) { - str, err := json.Marshal(apicache) + str, err := json.MarshalIndent(apicache, "", " ") return string(str), err } @@ -77,9 +80,7 @@ func CacheCreate(w http.ResponseWriter, r *http.Request) { if err := json.Unmarshal(body, &postcache); err != nil { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(422) // unprocessable entity - if err := json.NewEncoder(w).Encode(err); err != nil { - panic(err) - } + panic(err) } filename := uuid.New() + ".mp3" |