Documentation
¶
Index ¶
- type APITool
- func (a *APITool) Delete(ctx context.Context, url string, headers map[string]string) (*interfaces.ToolOutput, error)
- func (a *APITool) Get(ctx context.Context, url string, headers map[string]string) (*interfaces.ToolOutput, error)
- func (a *APITool) Patch(ctx context.Context, url string, body interface{}, headers map[string]string) (*interfaces.ToolOutput, error)
- func (a *APITool) Post(ctx context.Context, url string, body interface{}, headers map[string]string) (*interfaces.ToolOutput, error)
- func (a *APITool) Put(ctx context.Context, url string, body interface{}, headers map[string]string) (*interfaces.ToolOutput, error)
- type APIToolBuilder
- func (b *APIToolBuilder) Build() *APITool
- func (b *APIToolBuilder) WithAuth(token string) *APIToolBuilder
- func (b *APIToolBuilder) WithBaseURL(baseURL string) *APIToolBuilder
- func (b *APIToolBuilder) WithHeader(key, value string) *APIToolBuilder
- func (b *APIToolBuilder) WithHeaders(headers map[string]string) *APIToolBuilder
- func (b *APIToolBuilder) WithTimeout(timeout time.Duration) *APIToolBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APITool ¶
APITool HTTP API 调用工具
提供通用的 HTTP 请求能力,使用统一的 HTTP 客户端管理器
func NewAPITool ¶
NewAPITool 创建 API 工具
Parameters:
- baseURL: 基础 URL(可选,为空则每次请求需要提供完整 URL)
- timeout: 请求超时时间
- headers: 默认请求头
func (*APITool) Delete ¶
func (a *APITool) Delete(ctx context.Context, url string, headers map[string]string) (*interfaces.ToolOutput, error)
Delete 执行 DELETE 请求的便捷方法
func (*APITool) Get ¶
func (a *APITool) Get(ctx context.Context, url string, headers map[string]string) (*interfaces.ToolOutput, error)
Get 执行 GET 请求的便捷方法
func (*APITool) Patch ¶
func (a *APITool) Patch(ctx context.Context, url string, body interface{}, headers map[string]string) (*interfaces.ToolOutput, error)
Patch 执行 PATCH 请求的便捷方法
type APIToolBuilder ¶
type APIToolBuilder struct {
// contains filtered or unexported fields
}
APIToolBuilder API 工具构建器
func (*APIToolBuilder) WithAuth ¶
func (b *APIToolBuilder) WithAuth(token string) *APIToolBuilder
WithAuth 设置认证头
func (*APIToolBuilder) WithBaseURL ¶
func (b *APIToolBuilder) WithBaseURL(baseURL string) *APIToolBuilder
WithBaseURL 设置基础 URL
func (*APIToolBuilder) WithHeader ¶
func (b *APIToolBuilder) WithHeader(key, value string) *APIToolBuilder
WithHeader 添加默认请求头
func (*APIToolBuilder) WithHeaders ¶
func (b *APIToolBuilder) WithHeaders(headers map[string]string) *APIToolBuilder
WithHeaders 批量添加默认请求头
func (*APIToolBuilder) WithTimeout ¶
func (b *APIToolBuilder) WithTimeout(timeout time.Duration) *APIToolBuilder
WithTimeout 设置超时
Click to show internal directories.
Click to hide internal directories.