优化插件的参数请求

This commit is contained in:
Yun
2024-01-01 14:10:18 +08:00
parent c7c03ab1d3
commit 5159d5d258
6 changed files with 238 additions and 102 deletions
+34
View File
@@ -0,0 +1,34 @@
package curlx
import "time"
type clientOptions struct {
TimeOut time.Duration
InsecureSkipVerify bool
}
func defaultOptions() clientOptions {
return clientOptions{
TimeOut: time.Second * 120, // 默认超时120
}
}
type Option func(*clientOptions)
/**
* 设置超时时间
*/
func SetTimeOut(t time.Duration) Option {
return func(options *clientOptions) {
options.TimeOut = t
}
}
/**
* 不校验HTTPS证书
*/
func SetTLSInsecureSkipVerify() Option {
return func(options *clientOptions) {
options.InsecureSkipVerify = true
}
}