MCPcopy Index your code
hub / github.com/0xUnixIO/pulse / handleNodeStop

Method handleNodeStop

internal/serverapi/api.go:537–555  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, nodeID string)

Source from the content-addressed store, hash-verified

535}
536
537func (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
557func (a *API) handleNodeRestart(w http.ResponseWriter, r *http.Request, nodeID string) {
558 if r.Method != http.MethodPost {

Callers 1

handleNodeRoutesMethod · 0.95

Calls 6

clientForMethod · 0.95
writeMethodNotAllowedFunction · 0.85
writeNodeErrorFunction · 0.85
writeJSONFunction · 0.70
StopMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected