(w http.ResponseWriter, r *http.Request, nodeID string)
| 511 | } |
| 512 | |
| 513 | func (a *API) handleNodeStart(w http.ResponseWriter, r *http.Request, nodeID string) { |
| 514 | if r.Method != http.MethodPost { |
| 515 | writeMethodNotAllowed(w, http.MethodPost) |
| 516 | return |
| 517 | } |
| 518 | req, ok := decodeConfigRequest(w, r) |
| 519 | if !ok { |
| 520 | return |
| 521 | } |
| 522 | client, err := a.clientFor(nodeID) |
| 523 | if err != nil { |
| 524 | writeNodeError(w, err) |
| 525 | return |
| 526 | } |
| 527 | ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second) |
| 528 | defer cancel() |
| 529 | out, err := client.Start(ctx, nodes.ConfigRequest{Config: req.Config}) |
| 530 | if err != nil { |
| 531 | writeJSON(w, http.StatusUnprocessableEntity, map[string]any{"error": err.Error()}) |
| 532 | return |
| 533 | } |
| 534 | writeJSON(w, http.StatusOK, out) |
| 535 | } |
| 536 | |
| 537 | func (a *API) handleNodeStop(w http.ResponseWriter, r *http.Request, nodeID string) { |
| 538 | if r.Method != http.MethodPost { |
no test coverage detected