aboutsummaryrefslogtreecommitdiff
path: root/handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'handlers.go')
-rw-r--r--handlers.go11
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"