package api import ( "encoding/json" "net/http" ) func writeJSON(w http.ResponseWriter, status int, v any) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) json.NewEncoder(w).Encode(v) } type errorResponse struct { Code string `json:"code"` Message string `json:"message"` } func writeError(w http.ResponseWriter, status int, code, message string) { writeJSON(w, status, errorResponse{Code: code, Message: message}) }