writeJSON writes a JSON response
(w http.ResponseWriter, status int, v any)
| 27 | |
| 28 | // writeJSON writes a JSON response |
| 29 | func writeJSON(w http.ResponseWriter, status int, v any) { |
| 30 | w.Header().Set("Content-Type", "application/json") |
| 31 | w.WriteHeader(status) |
| 32 | _ = json.NewEncoder(w).Encode(v) // Ignore write errors after status sent |
| 33 | } |
| 34 | |
| 35 | // corsMiddleware adds CORS headers |
| 36 | func corsMiddleware(next http.Handler) http.Handler { |
no test coverage detected