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

Method handleChat

pkg/desktop/bridge_web.go:165–200  ·  view source on GitHub ↗

HTTP Handlers

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

163// HTTP Handlers
164
165func (b *WebBridge) handleChat(w http.ResponseWriter, r *http.Request) {
166 if r.Method != http.MethodPost {
167 http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
168 return
169 }
170
171 var req struct {
172 AgentID string `json:"agent_id"`
173 Message string `json:"message"`
174 }
175
176 if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
177 writeJSON(w, http.StatusBadRequest, BackendResponse{
178 Success: false,
179 Error: err.Error(),
180 })
181 return
182 }
183
184 resp, err := b.handler(&FrontendMessage{
185 ID: generateID(),
186 Type: MsgTypeChat,
187 AgentID: req.AgentID,
188 Payload: mustMarshal(ChatPayload{Message: req.Message}),
189 })
190
191 if err != nil {
192 writeJSON(w, http.StatusInternalServerError, BackendResponse{
193 Success: false,
194 Error: err.Error(),
195 })
196 return
197 }
198
199 writeJSON(w, http.StatusOK, resp)
200}
201
202func (b *WebBridge) handleCancel(w http.ResponseWriter, r *http.Request) {
203 if r.Method != http.MethodPost {

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected