mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
Merge branch 'master' of https://github.com/gogf/gf
This commit is contained in:
@ -46,6 +46,8 @@ type Config struct {
|
||||
IdleTimeout time.Duration // Maximum idle time for connection (default is 10 seconds, not allowed to be set to 0)
|
||||
MaxConnLifetime time.Duration // Maximum lifetime of the connection (default is 30 seconds, not allowed to be set to 0)
|
||||
ConnectTimeout time.Duration // Dial connection timeout.
|
||||
TLS bool // Specifies the config to use when a TLS connection is dialed.
|
||||
TLSSkipVerify bool // Disables server name verification when connecting over TLS
|
||||
}
|
||||
|
||||
// Pool statistics.
|
||||
@ -102,6 +104,8 @@ func New(config Config) *Redis {
|
||||
"tcp",
|
||||
fmt.Sprintf("%s:%d", config.Host, config.Port),
|
||||
redis.DialConnectTimeout(config.ConnectTimeout),
|
||||
redis.DialUseTLS(config.TLS),
|
||||
redis.DialTLSSkipVerify(config.TLSSkipVerify),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -110,6 +110,12 @@ func ConfigFromStr(str string) (config Config, err error) {
|
||||
if v, ok := parse["maxConnLifetime"]; ok {
|
||||
config.MaxConnLifetime = gconv.Duration(v) * time.Second
|
||||
}
|
||||
if v, ok := parse["tls"]; ok {
|
||||
config.TLS = gconv.Bool(v)
|
||||
}
|
||||
if v, ok := parse["skipVerify"]; ok {
|
||||
config.TLSSkipVerify = gconv.Bool(v)
|
||||
}
|
||||
return
|
||||
}
|
||||
array, _ = gregex.MatchString(`([^:]+):*(\d*),{0,1}(\d*),{0,1}(.*)`, str)
|
||||
|
||||
@ -135,7 +135,7 @@ func (c *Client) DoRequest(method, url string, data ...interface{}) (resp *Clien
|
||||
if !gfile.Exists(path) {
|
||||
return nil, errors.New(fmt.Sprintf(`"%s" does not exist`, path))
|
||||
}
|
||||
if file, err := writer.CreateFormFile(array[0], path); err == nil {
|
||||
if file, err := writer.CreateFormFile(array[0], gfile.Basename(path)); err == nil {
|
||||
if f, err := os.Open(path); err == nil {
|
||||
if _, err = io.Copy(file, f); err != nil {
|
||||
f.Close()
|
||||
|
||||
Reference in New Issue
Block a user