package controller import ( "encoding/json" "net/http" ) func jsonResponse(w http.ResponseWriter, data interface{}, status int) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) json.NewEncoder(w).Encode(data) } func jsonError(w http.ResponseWriter, message string, status int) { jsonResponse(w, map[string]string{"error": message}, status) } func jsonMsg(w http.ResponseWriter, message string) { jsonResponse(w, map[string]string{"msg": message}, http.StatusOK) }