(w http.ResponseWriter, r *http.Request, nodeID string)
| 535 | } |
| 536 | |
| 537 | func (a *API) handleNodeStop(w http.ResponseWriter, r *http.Request, nodeID string) { |
| 538 | if r.Method != http.MethodPost { |
| 539 | writeMethodNotAllowed(w, http.MethodPost) |
| 540 | return |
| 541 | } |
| 542 | client, err := a.clientFor(nodeID) |
| 543 | if err != nil { |
| 544 | writeNodeError(w, err) |
| 545 | return |
| 546 | } |
| 547 | ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second) |
| 548 | defer cancel() |
| 549 | out, err := client.Stop(ctx) |
| 550 | if err != nil { |
| 551 | writeJSON(w, http.StatusUnprocessableEntity, map[string]any{"error": err.Error()}) |
| 552 | return |
| 553 | } |
| 554 | writeJSON(w, http.StatusOK, out) |
| 555 | } |
| 556 | |
| 557 | func (a *API) handleNodeRestart(w http.ResponseWriter, r *http.Request, nodeID string) { |
| 558 | if r.Method != http.MethodPost { |
no test coverage detected