Add crazy struct flattening code

This commit is contained in:
Justin Li
2014-07-24 19:35:15 -04:00
parent 788b349dd7
commit ab43e6bd97
3 changed files with 126 additions and 39 deletions

View File

@@ -29,8 +29,15 @@ func (s *Server) check(w http.ResponseWriter, r *http.Request, p httprouter.Para
func (s *Server) stats(w http.ResponseWriter, r *http.Request, p httprouter.Params) (int, error) {
w.Header().Set("Content-Type", jsonContentType)
var err error
e := json.NewEncoder(w)
err := e.Encode(stats.DefaultStats)
if _, flatten := r.URL.Query()["flatten"]; flatten {
err = e.Encode(stats.DefaultStats.Flattened())
} else {
err = e.Encode(stats.DefaultStats)
}
if err != nil {
return http.StatusInternalServerError, err
}