Documentation
¶
Index ¶
- func ClearQuestLog()
- func SetDefaultCacheFunc(t CacheInterface)
- func SetDefaultCacheTime(t time.Duration)
- func SetDefaultTimeOut(t time.Duration)
- func SetQuestLog(f func(c *CURL))
- type CURL
- func (c *CURL) Authorization(token string) *CURL
- func (c *CURL) Cookie(cookie_param []string) *CURL
- func (c *CURL) Download(file string) *CURL
- func (c *CURL) DownloadIO(f io.Writer) *CURL
- func (c *CURL) Get() *CURL
- func (c *CURL) Header(h map[string]string) *CURL
- func (c *CURL) HeaderKV(k, v string) *CURL
- func (c *CURL) Param(m map[string]string) *CURL
- func (c *CURL) ParamJson(m map[string]any) *CURL
- func (c *CURL) ParamKV(k, v string) *CURL
- func (c *CURL) Post() *CURL
- func (c *CURL) PostJson() *CURL
- func (c *CURL) WithOption(opts ...OptionFunc) *CURL
- type CacheInterface
- type Option
- type OptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetQuestLog ¶
func SetQuestLog(f func(c *CURL))
设置Quest请求日志
f 日志记录函数【此函数会记录多个,所以请勿一直调用SetQuestLog进行插入日志记录函数】
Types ¶
type CURL ¶
type CURL struct { Uri string `json:"uri"` // 请求网址 Param_quest map[string]string `json:"param"` // 请求参数 HttpCode int `json:"http_code"` // HTTP返回的code值 ParamJson_quest map[string]any `json:"param_json"` // JSON推送参数 Body string `json:"body"` // 返回值 Error error `json:"error"` // 错误信息 Header_quest map[string]string `json:"header"` // 请求Header头 CreateTime time.Time `json:"create_time"` // 实例创建时间 StartTime time.Time `json:"start_time"` // 请求开始时间 EndTime time.Time `json:"end_time"` // 请求结束时间 ClientIp string `json:"client_ip"` // 请求的客户端IP【兼容日志处理模块的预留字段】 Cookie_quest []string `json:"cookie"` // HTTP网址返回的Set-Cookie相应头 // contains filtered or unexported fields }
网址服务对象
func New ¶
func New(url string, opts ...OptionFunc) *CURL
声明URL请求结构信息
url 要请求的网址信息 opts 可选参数,针对此网址进行的配置项追加
func (*CURL) ParamJson ¶
JSON格式的请求参数追加
m 追加的参数列表(可直接传入map[string]any{"_":xxx}(会在map最外层有且仅有_下标时才会直接取其内容进行传输))
func (*CURL) WithOption ¶
func (c *CURL) WithOption(opts ...OptionFunc) *CURL
设置Option选项[此参数需要在Get/Post/PostJson之前进行调用,若在之后调用的话会失去作用]
opts 可选参数,针对此网址进行的配置项追加
type CacheInterface ¶
type CacheInterface interface { Get(name string) string // 获取缓存值,缓存未找到的话请返回空字符串 Set(name string, val string, t time.Duration) // 设置缓存值,可能存在部分无法在string中正常显示的字符串 }
缓存钩子
type OptionFunc ¶
type OptionFunc func(c *Option)
选项设置参数,用于设置本次请求中的选项信息
func WithIgnoreHeader ¶
func WithIgnoreHeader(k string) OptionFunc
Source Files
¶
Click to show internal directories.
Click to hide internal directories.