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

Method handleNodeUsage

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

Source from the content-addressed store, hash-verified

491}
492
493func (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
513func (a *API) handleNodeStart(w http.ResponseWriter, r *http.Request, nodeID string) {
514 if r.Method != http.MethodPost {

Callers 1

handleNodeRoutesMethod · 0.95

Calls 6

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

Tested by

no test coverage detected