(w http.ResponseWriter, v interface{})
| 131 | } |
| 132 | |
| 133 | func httpJSON(w http.ResponseWriter, v interface{}) { |
| 134 | w.Header().Set("Content-Type", "application/json") |
| 135 | encoder := json.NewEncoder(w) |
| 136 | encoder.SetIndent("", " ") |
| 137 | if err := encoder.Encode(v); err != nil { |
| 138 | httpError(w, http.StatusInternalServerError) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | func httpError(w http.ResponseWriter, code int) { |
| 143 | http.Error(w, http.StatusText(code), code) |
no test coverage detected