(listFn func() ([]ProjectEntry, error))
| 30 | } |
| 31 | |
| 32 | func handleProjects(listFn func() ([]ProjectEntry, error)) http.HandlerFunc { |
| 33 | return func(w http.ResponseWriter, _ *http.Request) { |
| 34 | if listFn == nil { |
| 35 | writeJSON(w, []ProjectEntry{}) |
| 36 | return |
| 37 | } |
| 38 | projects, err := listFn() |
| 39 | if err != nil { |
| 40 | http.Error(w, err.Error(), http.StatusInternalServerError) |
| 41 | return |
| 42 | } |
| 43 | if projects == nil { |
| 44 | projects = []ProjectEntry{} |
| 45 | } |
| 46 | writeJSON(w, projects) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | func handleConfig(cfg Config) http.HandlerFunc { |
| 51 | phases := cfg.Phases |