Permalink
Browse files

fail if protocol is `https://`

  • Loading branch information...
Crunch09 committed Oct 12, 2017
1 parent 87c2ca2 commit b432780e4e8b0b89d6a1a57efc22042ee3ac2007
Showing with 5 additions and 3 deletions.
  1. +5 −3 client/client.go
View
@@ -10,8 +10,9 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"regexp"
"strings"
)
// Client holds information about where to connect to Toxiproxy.
@@ -47,8 +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 {
protocolProvided, _ := regexp.MatchString(`^https?://`, endpoint)
if !protocolProvided {
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 b432780

Please sign in to comment.