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

Function parseParams

pkg/a2a/server.go:287–303  ·  view source on GitHub ↗

============== 辅助函数 ============== parseParams 解析 JSON-RPC 参数

(params any, target any)

Source from the content-addressed store, hash-verified

285
286// parseParams 解析 JSON-RPC 参数
287func parseParams(params any, target any) error {
288 if params == nil {
289 return errors.New("params is required")
290 }
291
292 // 先序列化再反序列化,确保类型正确
293 data, err := json.Marshal(params)
294 if err != nil {
295 return fmt.Errorf("marshal params: %w", err)
296 }
297
298 if err := json.Unmarshal(data, target); err != nil {
299 return fmt.Errorf("unmarshal params: %w", err)
300 }
301
302 return nil
303}
304
305// extractText 从 Parts 中提取文本
306func extractText(parts []Part) string {

Callers 3

handleMessageSendMethod · 0.85
handleTasksGetMethod · 0.85
handleTasksCancelMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected