(w http.ResponseWriter, r *http.Request)
| 293 | } |
| 294 | |
| 295 | func (b *WebBridge) handleConfig(w http.ResponseWriter, r *http.Request) { |
| 296 | switch r.Method { |
| 297 | case http.MethodGet: |
| 298 | resp, _ := b.handler(&FrontendMessage{ |
| 299 | ID: generateID(), |
| 300 | Type: MsgTypeGetConfig, |
| 301 | }) |
| 302 | writeJSON(w, http.StatusOK, resp) |
| 303 | |
| 304 | case http.MethodPost, http.MethodPut: |
| 305 | var cfg ConfigPayload |
| 306 | if err := json.NewDecoder(r.Body).Decode(&cfg); err != nil { |
| 307 | writeJSON(w, http.StatusBadRequest, BackendResponse{ |
| 308 | Success: false, |
| 309 | Error: err.Error(), |
| 310 | }) |
| 311 | return |
| 312 | } |
| 313 | |
| 314 | resp, _ := b.handler(&FrontendMessage{ |
| 315 | ID: generateID(), |
| 316 | Type: MsgTypeSetConfig, |
| 317 | Payload: mustMarshal(cfg), |
| 318 | }) |
| 319 | writeJSON(w, http.StatusOK, resp) |
| 320 | |
| 321 | default: |
| 322 | http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | func (b *WebBridge) handleAgents(w http.ResponseWriter, r *http.Request) { |
| 327 | b.agentsMu.RLock() |
nothing calls this directly
no test coverage detected