mirror of
https://github.com/status-im/consul.git
synced 2025-02-16 23:57:07 +00:00
Merge pull request #3072 from hashicorp/api-httpclient
Tweaks to api's TLS logic in NewClient
This commit is contained in:
commit
c897d851aa
11
api/api.go
11
api/api.go
@ -369,10 +369,6 @@ func NewClient(config *Config) (*Client, error) {
|
|||||||
config.Transport = defConfig.Transport
|
config.Transport = defConfig.Transport
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.HttpClient == nil {
|
|
||||||
config.HttpClient = defConfig.HttpClient
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.TLSConfig.Address == "" {
|
if config.TLSConfig.Address == "" {
|
||||||
config.TLSConfig.Address = defConfig.TLSConfig.Address
|
config.TLSConfig.Address = defConfig.TLSConfig.Address
|
||||||
}
|
}
|
||||||
@ -434,6 +430,11 @@ func NewClient(config *Config) (*Client, error) {
|
|||||||
// NewHttpClient returns an http client configured with the given Transport and TLS
|
// NewHttpClient returns an http client configured with the given Transport and TLS
|
||||||
// config.
|
// config.
|
||||||
func NewHttpClient(transport *http.Transport, tlsConf TLSConfig) (*http.Client, error) {
|
func NewHttpClient(transport *http.Transport, tlsConf TLSConfig) (*http.Client, error) {
|
||||||
|
client := &http.Client{
|
||||||
|
Transport: transport,
|
||||||
|
}
|
||||||
|
|
||||||
|
if transport.TLSClientConfig == nil {
|
||||||
tlsClientConfig, err := SetupTLSConfig(&tlsConf)
|
tlsClientConfig, err := SetupTLSConfig(&tlsConf)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -441,8 +442,6 @@ func NewHttpClient(transport *http.Transport, tlsConf TLSConfig) (*http.Client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
transport.TLSClientConfig = tlsClientConfig
|
transport.TLSClientConfig = tlsClientConfig
|
||||||
client := &http.Client{
|
|
||||||
Transport: transport,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return client, nil
|
return client, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user