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

Method ListVolumes

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

ListVolumes handles GET /docker/volumes.

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

Source from the content-addressed store, hash-verified

289
290// ListVolumes handles GET /docker/volumes.
291func (h *DockerHandler) ListVolumes(w http.ResponseWriter, r *http.Request) {
292 q := r.URL.Query()
293 page := parseIntQuery(r, "page", 1)
294 limit := parseIntQuery(r, "limit", 50)
295 search := q.Get("search")
296 if len(search) > 200 {
297 search = search[:200]
298 }
299 params := store.VolumeListParams{
300 Driver: q.Get("driver"),
301 Search: search,
302 Page: page,
303 Limit: limit,
304 }
305 volumes, total, err := h.docker.ListVolumes(r.Context(), params)
306 if err != nil {
307 Error(w, http.StatusInternalServerError, "Failed to fetch volumes")
308 return
309 }
310 pages := (total + params.Limit - 1) / params.Limit
311 if pages < 1 {
312 pages = 1
313 }
314 JSON(w, http.StatusOK, map[string]interface{}{
315 "volumes": volumes,
316 "pagination": map[string]interface{}{
317 "page": page,
318 "limit": params.Limit,
319 "total": total,
320 "totalPages": pages,
321 },
322 })
323}
324
325// GetVolume handles GET /docker/volumes/:id.
326func (h *DockerHandler) GetVolume(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
ListVolumesMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected