diff --git a/registry/consul_registry.go b/registry/consul_registry.go index 2f09ab41..62344f35 100644 --- a/registry/consul_registry.go +++ b/registry/consul_registry.go @@ -59,14 +59,6 @@ func newConsulRegistry(opts ...Option) Registry { config = c } } - if config.HttpClient == nil { - config.HttpClient = new(http.Client) - } - - // set timeout - if options.Timeout > 0 { - config.HttpClient.Timeout = options.Timeout - } // check if there are any addrs if len(options.Addrs) > 0 { @@ -82,6 +74,10 @@ func newConsulRegistry(opts ...Option) Registry { // requires secure connection? if options.Secure || options.TLSConfig != nil { + if config.HttpClient == nil { + config.HttpClient = new(http.Client) + } + config.Scheme = "https" // We're going to support InsecureSkipVerify config.HttpClient.Transport = newTransport(options.TLSConfig) @@ -90,6 +86,11 @@ func newConsulRegistry(opts ...Option) Registry { // create the client client, _ := consul.NewClient(config) + // set timeout + if options.Timeout > 0 { + config.HttpClient.Timeout = options.Timeout + } + cr := &consulRegistry{ Address: config.Address, Client: client,