Create transport package (#1838)
This commit is contained in:
parent
f9c2220516
commit
5e586fcea4
15 changed files with 151 additions and 90 deletions
|
|
@ -1,22 +0,0 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// DefaultTransport returns http.DefaultTransport as http.Transport instead of http.RoundTripper
|
||||
func DefaultTransport() *http.Transport {
|
||||
t, ok := http.DefaultTransport.(*http.Transport)
|
||||
if !ok {
|
||||
panic("http.DefaultTransport is not an http.Transport")
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// InsecureTransport is an http.Transport with TLSClientConfig.InsecureSkipVerify enabled
|
||||
func InsecureTransport() *http.Transport {
|
||||
t := DefaultTransport()
|
||||
t.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
return t
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue