package utils import ( "encoding/json" "net/http" ) // Helper to write JSON responses func RespondWithJSON(w http.ResponseWriter, data any, statusCode int) { jsonData, err := json.Marshal(data) if err != nil { http.Error(w, "failed to marshal JSON", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json") w.WriteHeader(statusCode) w.Write(jsonData) }