Documentation
¶
Index ¶
Constants ¶
View Source
const ( POST = "POST" GET = "GET" PUT = "PUT" DELETE = "DELETE" OPTIONS = "OPTIONS" HTTP = "HTTP" HTTPS = "HTTPS" TCP = "TCP" WEBSOCKET = "WEBSOCKET" WEBSOCKETS = "WEBSOCKETS" ErrRequest = -1 // 请求失败 ErrCheck = -2 // 校验失败 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CMap ¶ added in v0.1.0
type FileProvider ¶ added in v0.1.0
type FileProvider struct {
// contains filtered or unexported fields
}
FileProvider 文件语料提供器,支持 TXT/CSV/XLSX 格式,线程安全轮询读取
func NewFileProvider ¶ added in v0.1.0
func NewFileProvider(path, sheet, column string) (*FileProvider, error)
NewFileProvider 根据文件扩展名创建对应的 FileProvider
func (*FileProvider) Next ¶ added in v0.1.0
func (f *FileProvider) Next() string
Next 返回当前行并将游标前移,到达末尾后回绕到 0,线程安全
type HttpRequest ¶ added in v0.1.0
type HttpRequest struct {
URL string `json:"url,omitempty"` // 请求地址
Method string `json:"method,omitempty"` // 请求方法 GET/ POST/ PUT/ DELETE/ OPTIONS
Headers map[string]string `json:"headers,omitempty"` // 请求头 Headers
Body string `json:"body,omitempty"` // 请求体 body
Verify []verify `json:"verify,omitempty"` // 验证的方法
Timeout time.Duration `json:"timeout,omitempty"` // 请求超时时间 s
Debug bool `json:"debug,omitempty"` // 是否开启Debug模式
MaxCon int `json:"maxCon,omitempty"` // 每个连接的请求数
SSL bool `json:"SSL,omitempty"` // 证书验证
Keepalive bool `json:"keepalive,omitempty"` // 是否开启长连接
Redirect bool `json:"redirect,omitempty"` // 是否重定向
Streaming bool `json:"streaming,omitempty"` // 是否为流式响应(SSE)
// contains filtered or unexported fields
}
HttpRequest 请求对象
func (*HttpRequest) AddCookies ¶ added in v0.1.0
func (h *HttpRequest) AddCookies(cookies ...*http.Cookie)
func (*HttpRequest) InitTemplates ¶ added in v0.1.0
func (h *HttpRequest) InitTemplates(needsBody bool) error
InitTemplates 预解析 URL、Headers、Body 中的模板变量
func (*HttpRequest) Send ¶ added in v0.1.0
func (h *HttpRequest) Send() *Response
Send 发送当前的 HTTP 请求并返回一个 Response 对象。
func (*HttpRequest) SetRegistry ¶ added in v0.1.0
func (h *HttpRequest) SetRegistry(registry *VariableRegistry)
SetRegistry 设置变量注册表
func (*HttpRequest) String ¶ added in v0.1.0
func (h *HttpRequest) String() string
func (*HttpRequest) Validate ¶ added in v0.1.0
func (h *HttpRequest) Validate() error
type Request ¶ added in v0.1.0
type Request interface {
String() string // 格式化打印 请求信息
Send() *Response // 发送请求
AddCookies(cookies ...*http.Cookie) // 设置cookie
Validate() error // 校验请求配置
InitTemplates(needsBody bool) error // 初始化模板
SetRegistry(registry *VariableRegistry) // 设置变量注册表
}
Request 请求对象接口
func NewHttpClient ¶ added in v0.1.0
NewHttpClient 从指定 JSON 文件中读取请求配置并返回 Request 接口切片
type Response ¶ added in v0.1.0
type Segment ¶ added in v0.1.0
type Segment struct {
// contains filtered or unexported fields
}
Segment 表示模板中的一个片段,可以是静态文本或变量引用
type Template ¶ added in v0.1.0
type Template struct {
// contains filtered or unexported fields
}
Template 表示解析后的模板,由多个片段组成
func ParseTemplate ¶ added in v0.1.0
ParseTemplate 将模板字符串解析为 Template 对象 支持 {{varName}} 语法,混合静态文本和变量引用
func (*Template) Execute ¶ added in v0.1.0
func (t *Template) Execute(registry *VariableRegistry) string
Execute 使用变量注册表执行模板,返回替换后的字符串
type VariableRegistry ¶ added in v0.1.0
type VariableRegistry struct {
// contains filtered or unexported fields
}
VariableRegistry 变量注册表,管理所有变量生成器
func NewVariableRegistry ¶ added in v0.1.0
func NewVariableRegistry(baseDir string) *VariableRegistry
NewVariableRegistry 创建新的变量注册表
func (*VariableRegistry) Resolve ¶ added in v0.1.0
func (r *VariableRegistry) Resolve(name string) string
Resolve 解析变量名,返回对应的值 支持的变量类型:
- "uuid" → UUID v4 字符串
- "counter" → 原子递增计数器(从 1 开始)
- "timestamp" → 当前 Unix 毫秒时间戳
- "random:min,max" → [min, max] 范围内的随机整数
- "resp:jsonpath" → 从响应值映射中查找
func (*VariableRegistry) SetRespValue ¶ added in v0.1.0
func (r *VariableRegistry) SetRespValue(path, value string)
SetRespValue 设置响应值,供 resp: 变量类型使用
Click to show internal directories.
Click to hide internal directories.