diff --git a/CHANGELOG.md b/CHANGELOG.md index 6269fa22..b452738a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Store all the executable `main` packages in `cmd` folder. (#335, @miry) * Extract common test helpers to own files. (#336, @miry) +* Client: Allow HTTPS endpoints. (#338, @chen-anders) # [2.2.0] diff --git a/client/client.go b/client/client.go index 4b97961f..45d959a7 100644 --- a/client/client.go +++ b/client/client.go @@ -10,7 +10,6 @@ import ( "fmt" "io" "io/ioutil" - "log" "net/http" "strings" ) @@ -48,9 +47,7 @@ type Proxy struct { // with Toxiproxy. Endpoint is the address to the proxy (e.g. localhost:8474 if // not overridden). func NewClient(endpoint string) *Client { - if strings.HasPrefix(endpoint, "https://") { - log.Fatal("the toxiproxy client does not support https") - } else if !strings.HasPrefix(endpoint, "http://") { + if !strings.HasPrefix(endpoint, "https://") && !strings.HasPrefix(endpoint, "http://") { endpoint = "http://" + endpoint } return &Client{endpoint: endpoint}