JSON writes a JSON response.
(w http.ResponseWriter, status int, v interface{})
| 7 | |
| 8 | // JSON writes a JSON response. |
| 9 | func JSON(w http.ResponseWriter, status int, v interface{}) { |
| 10 | w.Header().Set("Content-Type", "application/json") |
| 11 | w.WriteHeader(status) |
| 12 | if v != nil { |
| 13 | _ = json.NewEncoder(w).Encode(v) |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | // Error writes a JSON error response. |
| 18 | func Error(w http.ResponseWriter, status int, message string) { |
no test coverage detected