func restGetNeed(m *model.Model, w http.ResponseWriter, r *http.Request) { var qs = r.URL.Query() var folder = qs.Get("folder") progress, queued, rest := m.NeedFolderFiles(folder, 100) // Convert the struct to a more loose structure, and inject the size. output := map[string][]map[string]interface{}{ "progress": toNeedSlice(progress), "queued": toNeedSlice(queued), "rest": toNeedSlice(rest), } w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(output) }