MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / ListHosts

Method ListHosts

server-source-code/internal/handler/docker.go:248–269  ·  view source on GitHub ↗

ListHosts handles GET /docker/hosts.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

246
247// ListHosts handles GET /docker/hosts.
248func (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.
272func (h *DockerHandler) GetHostDockerDetail(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 4

parseIntQueryFunction · 0.85
ErrorFunction · 0.85
JSONFunction · 0.70
ListHostsMethod · 0.65

Tested by

no test coverage detected