modified so ?pretty=anything will work

This commit is contained in:
Eric Connell 2014-08-01 14:28:46 -06:00
parent e31c6b8b83
commit 6c3aaa81c1

View file

@ -138,13 +138,13 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque
} }
prettyPrint := false prettyPrint := false
if req.URL.Query().Get("pretty") == "true" { if req.URL.Query().Get("pretty") != "" {
prettyPrint = true prettyPrint = true
} }
// Write out the JSON object // Write out the JSON object
if obj != nil { if obj != nil {
var buf []byte var buf []byte
if prettyPrint == true { if prettyPrint {
buf, err = json.MarshalIndent(obj, "", " ") buf, err = json.MarshalIndent(obj, "", " ")
} else { } else {
buf, err = json.Marshal(obj) buf, err = json.Marshal(obj)