跳转至

协议调用

callasactl 顶层命令,用于按照协议定义执行动作。

用法

asactl call <agreement> -a <action> [flags]

参数

  • -a, --action <name>:动作名(必填)
  • -v, --version <ver>:协议版本(默认 latest
  • -h, --host <host>:远程地址
  • -q, --query <json>:输入参数 JSON
  • --insecure:跳过 TLS 校验(仅开发)

版本规则:

  • 统一使用带 v 前缀的精确版本号,例如 v1.0.0

示例

# local
asactl call auth -a login

# pinned version
asactl call auth -a login -v v1.0.0

# remote host
asactl call try -a ping -h https://service.example.com

# with parameters
asactl call auth -a userinfo -q '{"accessToken":"xxx"}'

远程调用模式

asactl call <agreement> -a <action> -v <version> -h <host> [-q <json>] [--insecure]

传输封装(NDJSON)

请求:

{"type":"request","request":{"requestid":1,"module":"account","action":"userinfo","param":{}}}

响应:

{"type":"response","response":{"requestid":1,"via":"cli","module":"account","action":"userinfo","ok":true,"data":{}}}

说明

  • call 会根据协议定义组装请求并校验参数。
  • 调用方不需要自行传递 via,运行时会自动注入。
  • -h 指向的地址必须已经实现目标 agreement。