ListHosts handles GET /docker/hosts.
(w http.ResponseWriter, r *http.Request)
| 246 | |
| 247 | // ListHosts handles GET /docker/hosts. |
| 248 | func (h *DockerHandler) ListHosts(w http.ResponseWriter, r *http.Request) { |
| 249 | page := parseIntQuery(r, "page", 1) |
| 250 | limit := parseIntQuery(r, "limit", 50) |
| 251 | hosts, total, err := h.docker.ListHosts(r.Context(), page, limit) |
| 252 | if err != nil { |
| 253 | Error(w, http.StatusInternalServerError, "Failed to fetch Docker hosts") |
| 254 | return |
| 255 | } |
| 256 | pages := (total + limit - 1) / limit |
| 257 | if pages < 1 { |
| 258 | pages = 1 |
| 259 | } |
| 260 | JSON(w, http.StatusOK, map[string]interface{}{ |
| 261 | "hosts": hosts, |
| 262 | "pagination": map[string]interface{}{ |
| 263 | "page": page, |
| 264 | "limit": limit, |
| 265 | "total": total, |
| 266 | "totalPages": pages, |
| 267 | }, |
| 268 | }) |
| 269 | } |
| 270 | |
| 271 | // GetHostDockerDetail handles GET /docker/hosts/:id. |
| 272 | func (h *DockerHandler) GetHostDockerDetail(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected