Hosts handles GET /dashboard/hosts.
(w http.ResponseWriter, r *http.Request)
| 39 | |
| 40 | // Hosts handles GET /dashboard/hosts. |
| 41 | func (h *DashboardHandler) Hosts(w http.ResponseWriter, r *http.Request) { |
| 42 | q := r.URL.Query() |
| 43 | search := q.Get("search") |
| 44 | if len(search) > 200 { |
| 45 | search = search[:200] |
| 46 | } |
| 47 | params := store.HostsListParams{ |
| 48 | Search: search, |
| 49 | Group: q.Get("group"), |
| 50 | Status: q.Get("status"), |
| 51 | OS: q.Get("os"), |
| 52 | OSVersion: q.Get("osVersion"), |
| 53 | } |
| 54 | hosts, err := h.dashboard.GetHostsWithCounts(r.Context(), params) |
| 55 | if err != nil { |
| 56 | Error(w, http.StatusInternalServerError, "Failed to load hosts") |
| 57 | return |
| 58 | } |
| 59 | JSON(w, http.StatusOK, hosts) |
| 60 | } |
| 61 | |
| 62 | // HostDetail handles GET /dashboard/hosts/:hostId. |
| 63 | func (h *DashboardHandler) HostDetail(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected