pretty-print API json responses
This commit is contained in:
parent
fdfc6b8c3e
commit
ff6d157e6b
3 changed files with 24 additions and 8 deletions
|
@ -27,7 +27,9 @@ func ServeAllArtists() http.Handler {
|
|||
}
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
err = json.NewEncoder(w).Encode(artists)
|
||||
encoder := json.NewEncoder(w)
|
||||
encoder.SetIndent("", "\t")
|
||||
err = encoder.Encode(artists)
|
||||
if err != nil {
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
}
|
||||
|
@ -74,7 +76,9 @@ func ServeArtist(artist *model.Artist) http.Handler {
|
|||
}
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
err = json.NewEncoder(w).Encode(artistJSON{
|
||||
encoder := json.NewEncoder(w)
|
||||
encoder.SetIndent("", "\t")
|
||||
err = encoder.Encode(artistJSON{
|
||||
Artist: artist,
|
||||
Credits: credits,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue