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

Method sendJSON

pkg/tools/bridge/http_server.go:232–239  ·  view source on GitHub ↗

sendJSON 发送 JSON 响应

(w http.ResponseWriter, data any)

Source from the content-addressed store, hash-verified

230
231// sendJSON 发送 JSON 响应
232func (s *HTTPBridgeServer) sendJSON(w http.ResponseWriter, data any) {
233 w.Header().Set("Content-Type", "application/json")
234 w.WriteHeader(http.StatusOK)
235 if err := json.NewEncoder(w).Encode(data); err != nil {
236 // 无法发送错误响应给客户端,仅记录日志
237 fmt.Fprintf(os.Stderr, "Failed to encode JSON response: %v\n", err)
238 }
239}
240
241// sendError 发送错误响应
242func (s *HTTPBridgeServer) sendError(w http.ResponseWriter, message string, statusCode int) {

Callers 4

handleToolCallMethod · 0.95
handleToolListMethod · 0.95
handleToolSchemaMethod · 0.95
handleHealthMethod · 0.95

Calls 1

SetMethod · 0.65

Tested by

no test coverage detected