mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
b62080c4bb
Former-commit-id: 49fcdb93106a78f0a24ad3fb4d8725e35e98451a
31 lines
535 B
Go
31 lines
535 B
Go
package netutil
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/kataras/golog"
|
|
)
|
|
|
|
// Client returns a new http.Client using
|
|
// the "timeout" for open connection.
|
|
func Client(timeout time.Duration) *http.Client {
|
|
transport := http.Transport{
|
|
Dial: func(network string, addr string) (net.Conn, error) {
|
|
conn, err := net.DialTimeout(network, addr, timeout)
|
|
if err != nil {
|
|
golog.Debugf("%v", err)
|
|
return nil, err
|
|
}
|
|
return conn, err
|
|
},
|
|
}
|
|
|
|
client := &http.Client{
|
|
Transport: &transport,
|
|
}
|
|
|
|
return client
|
|
}
|