1 Star 1 Fork 1

xiaoyutab / xgotool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
new.go 903 Bytes
一键复制 编辑 原始数据 按行查看 历史
package https
import (
"context"
"time"
)
// 声明URL请求结构信息
//
// url 要请求的网址信息
// opts 可选参数,针对此网址进行的配置项追加
func New(url string, opts ...OptionFunc) *CURL {
// 默认配置项加载
opt := Option{
time_out: _default.timeOut,
cache_time: _default.cacheTime,
jar: getJar(),
context: context.TODO(),
}
// 配置项设置
for i := 0; i < len(opts); i++ {
opts[i](&opt)
}
// 声明配置项的值
return &CURL{
Uri: url,
option: &opt,
CreateTime: time.Now(),
}
}
// 设置Option选项[此参数需要在Get/Post/PostJson之前进行调用,若在之后调用的话会失去作用]
//
// opts 可选参数,针对此网址进行的配置项追加
func (c *CURL) WithOption(opts ...OptionFunc) *CURL {
// 配置项设置
for i := 0; i < len(opts); i++ {
opts[i](c.option)
}
return c
}
Go
1
https://gitee.com/xiaoyutab/xgotool.git
git@gitee.com:xiaoyutab/xgotool.git
xiaoyutab
xgotool
xgotool
v0.3.11

搜索帮助

53164aa7 5694891 3bd8fe86 5694891