Permalink
Browse files

Merge pull request #191 from Crunch09/host_protocol

only prepend `http://` to endpoint if no protocol was provided
  • Loading branch information...
jpittis committed Oct 13, 2017
2 parents fe6bf4f + b432780 commit 87f5cccc7fb06487e05c2a6f45db79650bfefd67
Showing with 4 additions and 1 deletion.
  1. +4 −1 client/client.go
View
@@ -10,6 +10,7 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"strings"
)
@@ -47,7 +48,9 @@ type Proxy struct {
// with Toxiproxy. Endpoint is the address to the proxy (e.g. localhost:8474 if
// not overriden)
func NewClient(endpoint string) *Client {
if !strings.HasPrefix(endpoint, "http://") {
if strings.HasPrefix(endpoint, "https://") {
log.Fatal("the toxiproxy client does not support https")
} else if !strings.HasPrefix(endpoint, "http://") {
endpoint = "http://" + endpoint
}
return &Client{endpoint: endpoint}

0 comments on commit 87f5ccc

Please sign in to comment.