Skip to content

Commit af39cb6

Browse files
Fabian Hollerfho
authored andcommitted
honor CONSUL_HTTP_SSL environment variable
Instead of configuring the consul client with scheme = http, if not scheme is provider via the query string, pass an empty scheme. This allows to configure the scheme via the CONSUL_HTTP_SSL environment variable, that the consul client parses if no scheme is set.
1 parent 2aa92eb commit af39cb6

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The default for `<consul-server>` is `127.0.0.1:8500`.
2525

2626
| OPT | Format | Default | Description |
2727
|------------|---------------------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
28-
| scheme | `http\|https` | http | Establish connection to consul via http or https. |
28+
| scheme | `http\|https` | | Establish connection to consul via http or https. |
2929
| tags | `<tag>,[,<tag>]...` | | Filter service by tags |
3030
| health | `healthy\|fallbackToUnhealthy` | healthy | `healthy` resolves only to services with a passing health status.<br>`fallbackToUnhealthy` resolves to unhealthy ones if none exist with passing healthy status. |
3131
| token | `string` | | Authenticate Consul API Request with the token. |

consul/builder.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// OPT is one of:
1717
//
1818
// - scheme=http|https specifies if the connection to Consul is established
19-
// via HTTP or HTTPS. Default: http
19+
// via HTTP or HTTPS.
2020
// - tags=<tag>[,<tag>]... only resolves to instances that have the given
2121
// tags. Default: empty
2222
// - health=healthy|fallbackToUnhealthy filters Services by their health status.
@@ -88,7 +88,6 @@ func extractOpts(opts url.Values) (scheme string, tags []string, health healthFi
8888
}
8989

9090
func parseEndpoint(url *url.URL) (serviceName, scheme string, tags []string, health healthFilter, token string, err error) {
91-
const defScheme = "http"
9291
const defHealthFilter = healthFilterOnlyHealthy
9392

9493
// url.Path contains a leading "/", when the URL is in the form
@@ -103,10 +102,6 @@ func parseEndpoint(url *url.URL) (serviceName, scheme string, tags []string, hea
103102
return "", "", nil, health, "", err
104103
}
105104

106-
if scheme == "" {
107-
scheme = defScheme
108-
}
109-
110105
if health == healthFilterUndefined {
111106
health = defHealthFilter
112107
}

0 commit comments

Comments
 (0)