httptool

package
v0.0.0-...-1c978d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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 接口。

type Param

type Param struct {
	Type     string `json:"type"`     // string | number | integer | boolean
	Desc     string `json:"desc"`     // 给模型看的参数说明
	Required bool   `json:"required"` //
	In       string `json:"in"`       // path | query | body,默认:GET→query,其他→body
}

Param 描述一个接口参数及其注入位置。

type SourceConfig

type SourceConfig struct {
	Headers    map[string]string `json:"headers"` // 公共请求头
	TimeoutSec int               `json:"timeout_sec"`
	Tools      []Config          `json:"tools"`
}

SourceConfig 声明一批 HTTP 接口。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL