Ai
1 Star 0 Fork 0

小于的个人工具集/https

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
new.go 833 Bytes
一键复制 编辑 原始数据 按行查看 历史
xiaoyutab 提交于 2023-12-13 15:20 +08:00 . 完善时间留存记录字段
package https
import "time"
// 声明URL请求结构信息
//
// url 要请求的网址信息
// opts 可选参数,针对此网址进行的配置项追加
func New(url string, opts ...OptionFunc) *CURL {
// 默认配置项加载
opt := Option{
time_out: _default.timeOut,
cache_time: _default.cacheTime,
}
// 配置项设置
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
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xgotool/https.git
git@gitee.com:xgotool/https.git
xgotool
https
https
master

搜索帮助