(w http.ResponseWriter, r *http.Request, nodeID string)
| 491 | } |
| 492 | |
| 493 | func (a *API) handleNodeUsage(w http.ResponseWriter, r *http.Request, nodeID string) { |
| 494 | if r.Method != http.MethodGet { |
| 495 | writeMethodNotAllowed(w, http.MethodGet) |
| 496 | return |
| 497 | } |
| 498 | client, err := a.clientFor(nodeID) |
| 499 | if err != nil { |
| 500 | writeNodeError(w, err) |
| 501 | return |
| 502 | } |
| 503 | ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second) |
| 504 | defer cancel() |
| 505 | out, err := client.Usage(ctx, false) |
| 506 | if err != nil { |
| 507 | writeJSON(w, http.StatusUnprocessableEntity, map[string]any{"error": err.Error()}) |
| 508 | return |
| 509 | } |
| 510 | writeJSON(w, http.StatusOK, out) |
| 511 | } |
| 512 | |
| 513 | func (a *API) handleNodeStart(w http.ResponseWriter, r *http.Request, nodeID string) { |
| 514 | if r.Method != http.MethodPost { |
no test coverage detected