Create transport package (#1838)

This commit is contained in:
andig 2021-11-19 21:09:57 +01:00 • committed by GitHub
parent f9c2220516
commit 5e586fcea4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 151 additions and 90 deletions

View file

@ -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
}