http

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APITool

type APITool struct {
	*tools.BaseTool
	// contains filtered or unexported fields
}

APITool HTTP API 调用工具

提供通用的 HTTP 请求能力,使用统一的 HTTP 客户端管理器

func NewAPITool

func NewAPITool(baseURL string, timeout time.Duration, headers map[string]string) *APITool

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 请求的便捷方法

func (*APITool) Post

func (a *APITool) Post(ctx context.Context, url string, body interface{}, headers map[string]string) (*interfaces.ToolOutput, error)

Post 执行 POST 请求的便捷方法

func (*APITool) Put

func (a *APITool) Put(ctx context.Context, url string, body interface{}, headers map[string]string) (*interfaces.ToolOutput, error)

Put 执行 PUT 请求的便捷方法

type APIToolBuilder

type APIToolBuilder struct {
	// contains filtered or unexported fields
}

APIToolBuilder API 工具构建器

func NewAPIToolBuilder

func NewAPIToolBuilder() *APIToolBuilder

NewAPIToolBuilder 创建 API 工具构建器

func (*APIToolBuilder) Build

func (b *APIToolBuilder) Build() *APITool

Build 构建工具

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 设置超时

Jump to

Keyboard shortcuts

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