优化插件的参数请求
This commit is contained in:
+34
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user