MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / handleSetConfig

Method handleSetConfig

internal/ipsentinel/nodehandler.go:221–232  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

219}
220
221func (h *NodeHandler) handleSetConfig(w http.ResponseWriter, r *http.Request) {
222 var cfg Config
223 if err := json.NewDecoder(r.Body).Decode(&cfg); err != nil {
224 writeNodeJSON(w, http.StatusBadRequest, map[string]any{"error": "invalid json"})
225 return
226 }
227 if err := h.saveConfig(cfg); err != nil {
228 writeNodeJSON(w, http.StatusInternalServerError, map[string]any{"error": err.Error()})
229 return
230 }
231 writeNodeJSON(w, http.StatusOK, map[string]any{"ok": true})
232}
233
234func writeNodeJSON(w http.ResponseWriter, status int, payload any) {
235 w.Header().Set("Content-Type", "application/json; charset=utf-8")

Callers

nothing calls this directly

Calls 3

saveConfigMethod · 0.95
writeNodeJSONFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected