package httpserver import ( "encoding/json" "net/http" ) func writeJSON(w http.ResponseWriter, status int, payload any) { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(status) if err := json.NewEncoder(w).Encode(payload); err != nil { http.Error(w, "json encoding failed", http.StatusInternalServerError) } }