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

Method sendError

pkg/tools/bridge/http_server.go:242–251  ·  view source on GitHub ↗

sendError 发送错误响应

(w http.ResponseWriter, message string, statusCode int)

Source from the content-addressed store, hash-verified

240
241// sendError 发送错误响应
242func (s *HTTPBridgeServer) sendError(w http.ResponseWriter, message string, statusCode int) {
243 w.Header().Set("Content-Type", "application/json")
244 w.WriteHeader(statusCode)
245 if err := json.NewEncoder(w).Encode(map[string]string{
246 "error": message,
247 }); err != nil {
248 // 无法发送错误响应给客户端,仅记录日志
249 fmt.Fprintf(os.Stderr, "Failed to encode error response: %v\n", err)
250 }
251}
252
253// Start 启动服务器
254func (s *HTTPBridgeServer) Start() error {

Callers 2

handleToolCallMethod · 0.95
handleToolSchemaMethod · 0.95

Calls 1

SetMethod · 0.65

Tested by

no test coverage detected