Documentation
¶
Overview ¶
Package httptool 把 HTTP 接口声明为 Source:一段配置声明一批接口, 每个接口成为一个 cap://tool/<source名>/<接口名> 能力,无需写代码。
模型产出的参数按 In 字段分发:path 参数替换 URL 占位符,query 参数 拼到查询串,body 参数合并为 JSON 请求体。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(namespace string, cfg Config) (capability.Capability, error)
New 从配置构造 HTTP 工具能力,namespace 为所属 source 名。
Types ¶
type Config ¶
type Config struct {
Name string `json:"name"`
Description string `json:"description"`
Method string `json:"method"` // 默认 GET
URL string `json:"url"` // 支持 {param} 路径占位
Headers map[string]string `json:"headers"`
Params map[string]Param `json:"params"`
Risk string `json:"risk"` // 默认按 method 推断:GET→readonly,其他→mutating
TimeoutSec int `json:"timeout_sec"`
MaxRespLen int `json:"max_resp_len"`
}
Config 声明一个 HTTP 接口。
Click to show internal directories.
Click to hide internal directories.