Documentation
¶
Overview ¶
Package http 提供 HTTP API 调用工具
支持 REST API、GraphQL 等 HTTP 调用场景。
Index ¶
Constants ¶
View Source
const ( // MaxResponseBodySize 最大响应体大小(10MB) // 防止恶意服务器返回超大响应导致 OOM MaxResponseBodySize = 10 * 1024 * 1024 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GraphQLInput ¶
type GraphQLInput struct {
Query string `json:"query" description:"GraphQL 查询语句"`
Variables map[string]any `json:"variables,omitempty" description:"查询变量"`
}
GraphQLInput GraphQL 查询输入
type GraphQLOutput ¶
GraphQLOutput GraphQL 查询输出
type GraphQLTool ¶
type GraphQLTool struct {
// contains filtered or unexported fields
}
GraphQLTool GraphQL 工具
func NewGraphQLTool ¶
func NewGraphQLTool(endpoint string, opts ...Option) *GraphQLTool
NewGraphQLTool 创建 GraphQL 工具
type HTTPTool ¶
type HTTPTool struct {
// contains filtered or unexported fields
}
HTTPTool HTTP API 调用工具
type Option ¶
type Option func(*HTTPTool)
Option HTTP 工具选项
func WithAllowPrivateNetwork ¶
func WithAllowPrivateNetwork() Option
WithAllowPrivateNetwork 允许访问内网地址(默认禁止,防止 SSRF)
type RequestInput ¶
type RequestInput struct {
URL string `json:"url" description:"请求 URL"`
Method string `json:"method" description:"HTTP 方法 (GET/POST/PUT/DELETE)"`
Headers map[string]string `json:"headers,omitempty" description:"请求头"`
Body string `json:"body,omitempty" description:"请求体 (JSON 字符串)"`
}
RequestInput GET 请求输入
Click to show internal directories.
Click to hide internal directories.