Merge pull request #426 from printfcoder/master

solve consul.NewRegistry httpclient 'nil pointer dereference' bug
This commit is contained in:
Asim Aslam 2019-02-28 07:10:23 +00:00 committed by GitHub
commit 99c80d0878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,12 +105,13 @@ func configure(c *consulRegistry, opts ...registry.Option) {
}
}
// requires secure connection?
if c.opts.Secure || c.opts.TLSConfig != nil {
if config.HttpClient == nil {
config.HttpClient = new(http.Client)
}
// requires secure connection?
if c.opts.Secure || c.opts.TLSConfig != nil {
config.Scheme = "https"
// We're going to support InsecureSkipVerify
config.HttpClient.Transport = newTransport(c.opts.TLSConfig)