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

Method handleChat

pkg/desktop/bridge_electron.go:194–229  ·  view source on GitHub ↗

HTTP Handlers (delegated to common implementation)

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

Source from the content-addressed store, hash-verified

192// HTTP Handlers (delegated to common implementation)
193
194func (b *ElectronBridge) handleChat(w http.ResponseWriter, r *http.Request) {
195 if r.Method != http.MethodPost {
196 http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
197 return
198 }
199
200 var req struct {
201 AgentID string `json:"agent_id"`
202 Message string `json:"message"`
203 }
204
205 if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
206 writeJSON(w, http.StatusBadRequest, BackendResponse{
207 Success: false,
208 Error: err.Error(),
209 })
210 return
211 }
212
213 resp, err := b.handler(&FrontendMessage{
214 ID: generateID(),
215 Type: MsgTypeChat,
216 AgentID: req.AgentID,
217 Payload: mustMarshal(ChatPayload{Message: req.Message}),
218 })
219
220 if err != nil {
221 writeJSON(w, http.StatusInternalServerError, BackendResponse{
222 Success: false,
223 Error: err.Error(),
224 })
225 return
226 }
227
228 writeJSON(w, http.StatusOK, resp)
229}
230
231func (b *ElectronBridge) handleCancel(w http.ResponseWriter, r *http.Request) {
232 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