ListVolumes handles GET /docker/volumes.
(w http.ResponseWriter, r *http.Request)
| 289 | |
| 290 | // ListVolumes handles GET /docker/volumes. |
| 291 | func (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. |
| 326 | func (h *DockerHandler) GetVolume(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected