Skip to content

Commit

Permalink
Allow HTTPS endpoints in client (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anders Chen committed Oct 25, 2021
1 parent 5a3ea8a commit fc4a464
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
5 changes: 1 addition & 4 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"strings"
)
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit fc4a464

Please sign in to comment.