(w http.ResponseWriter, r *http.Request)
| 219 | } |
| 220 | |
| 221 | func (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 | |
| 234 | func writeNodeJSON(w http.ResponseWriter, status int, payload any) { |
| 235 | w.Header().Set("Content-Type", "application/json; charset=utf-8") |
nothing calls this directly
no test coverage detected