package respond import ( "encoding/json" "net/http" ) // JSON writes a JSON body with the given status code. func JSON(w http.ResponseWriter, status int, payload any) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) _ = json.NewEncoder(w).Encode(payload) } // Error writes a JSON error body: {"error": "message"}. func Error(w http.ResponseWriter, status int, msg string) { JSON(w, status, map[string]string{"error": msg}) }