MCPcopy Create free account
hub / github.com/astercloud/aster / handleConfig

Method handleConfig

pkg/desktop/bridge_web.go:295–324  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

293}
294
295func (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
326func (b *WebBridge) handleAgents(w http.ResponseWriter, r *http.Request) {
327 b.agentsMu.RLock()

Callers

nothing calls this directly

Calls 4

mustMarshalFunction · 0.85
generateIDFunction · 0.70
writeJSONFunction · 0.70
ErrorMethod · 0.65

Tested by

no test coverage detected