(w http.ResponseWriter, _ *http.Request, data interface{})
| 13 | ) |
| 14 | |
| 15 | func renderJSON(w http.ResponseWriter, _ *http.Request, data interface{}) (int, error) { |
| 16 | marsh, err := json.Marshal(data) |
| 17 | |
| 18 | if err != nil { |
| 19 | return http.StatusInternalServerError, err |
| 20 | } |
| 21 | |
| 22 | w.Header().Set("Content-Type", "application/json; charset=utf-8") |
| 23 | if _, err := w.Write(marsh); err != nil { |
| 24 | return http.StatusInternalServerError, err |
| 25 | } |
| 26 | |
| 27 | return 0, nil |
| 28 | } |
| 29 | |
| 30 | func errToStatus(err error) int { |
| 31 | switch { |
no outgoing calls
no test coverage detected