(w http.ResponseWriter, status int, payload any)
| 262 | } |
| 263 | |
| 264 | func writeJSON(w http.ResponseWriter, status int, payload any) { |
| 265 | w.Header().Set("Content-Type", "application/json; charset=utf-8") |
| 266 | w.WriteHeader(status) |
| 267 | if err := json.NewEncoder(w).Encode(payload); err != nil { |
| 268 | log.Printf("payment: write json: %v", err) |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | func writeJSONError(w http.ResponseWriter, status int, message string) { |
| 273 | writeJSON(w, status, map[string]string{"error": message}) |
no test coverage detected