Skip to content
This repository has been archived by the owner on Apr 27, 2019. It is now read-only.

Replacing http:// and https:// from CONSUL_HTTP_ADDR from env Variable #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Consul/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ public ConsulClientConfiguration()
private void ConfigureFromEnvironment(UriBuilder consulAddress)
{
var envAddr = (Environment.GetEnvironmentVariable("CONSUL_HTTP_ADDR") ?? string.Empty).Trim().ToLowerInvariant();

if (envAddr.Contains("http"))
envAddr = envAddr.Replace("http://", "").Replace("https://", "");

if (!string.IsNullOrEmpty(envAddr))
{
var addrParts = envAddr.Split(':');
Expand Down Expand Up @@ -651,7 +655,7 @@ public ConsulClient(ConsulClientConfiguration config)
config.Updated += HandleConfigUpdateEvent;
var ctr = new ConsulClientConfigurationContainer(config);
ApplyConfig(ctr.Config, ctr.HttpHandler, ctr.HttpClient);

ConfigContainer = ctr;
InitializeEndpoints();
}
Expand Down