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

Method ListNetworks

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

ListNetworks handles GET /docker/networks.

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

Source from the content-addressed store, hash-verified

360
361// ListNetworks handles GET /docker/networks.
362func (h *DockerHandler) ListNetworks(w http.ResponseWriter, r *http.Request) {
363 q := r.URL.Query()
364 page := parseIntQuery(r, "page", 1)
365 limit := parseIntQuery(r, "limit", 50)
366 search := q.Get("search")
367 if len(search) > 200 {
368 search = search[:200]
369 }
370 params := store.NetworkListParams{
371 Driver: q.Get("driver"),
372 Search: search,
373 Page: page,
374 Limit: limit,
375 }
376 networks, total, err := h.docker.ListNetworks(r.Context(), params)
377 if err != nil {
378 Error(w, http.StatusInternalServerError, "Failed to fetch networks")
379 return
380 }
381 pages := (total + params.Limit - 1) / params.Limit
382 if pages < 1 {
383 pages = 1
384 }
385 JSON(w, http.StatusOK, map[string]interface{}{
386 "networks": networks,
387 "pagination": map[string]interface{}{
388 "page": page,
389 "limit": params.Limit,
390 "total": total,
391 "totalPages": pages,
392 },
393 })
394}
395
396// GetNetwork handles GET /docker/networks/:id.
397func (h *DockerHandler) GetNetwork(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 6

parseIntQueryFunction · 0.85
ErrorFunction · 0.85
QueryMethod · 0.80
JSONFunction · 0.70
ListNetworksMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected