Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Log 日志输出函数,可修改 Log = func(v ...interface{}) { fmt.Println(v...) } )
View Source
var NilValueErr = errors.New("nil value")
NilValueErr 空值错误
Functions ¶
func PathEscape ¶
func PathEscapeEncode ¶ added in v0.1.8
func UrlPathEscape ¶
Types ¶
type Helper ¶
type Helper interface {
// AddQuery 添加Query参数
AddQuery(k string, v string) Helper
// AddQueryMap 通过map来添加Query参数
AddQueryMap(m map[string]string) Helper
// AddPathEscapeQuery 添加Query参数,并进行PathEscape转义
AddPathEscapeQuery(k string, v string) Helper
AddPathEscapeQueryMap(m map[string]string) Helper
// AddHeader 添加HTTP header
AddHeader(k string, v string) Helper
// SetHeader 设置HTTP header,会覆盖同名的header
SetHeader(k string, v string) Helper
// SetTransport 设置RoundTripper,可用于添加中间件
SetTransport(tripper http.RoundTripper) Helper
// AddCookies 设置完整cookies
AddCookies(c []*http.Cookie) Helper
// AddSimpleCookies 设置只有简单name和value的cookies
AddSimpleCookies(c map[string]string) Helper
// Do 发送请求
Do() Result
}
Helper http Helper接口的提供的方法
func NewRequest ¶
NewRequest 创建新的请求
type Result ¶
type Result interface {
// BaseResult 返回Http请求的基本结果,包含Status和Body
BaseResult() *baseResult
// StdCheck 检查HTTP响应码和Body中的Code
StdCheck() Result
// Bind 将返回值存储到Object中
Bind(object interface{}, path ...interface{}) error
// Get 通过json path获取子结果
Get(path ...interface{}) Result
// Error 返回出现的错误
Error() error
// Jsoniter 返回body的json迭代器
Jsoniter() jsoniter.Any
}
Result Http请求的结果
Click to show internal directories.
Click to hide internal directories.