Skip to content

Commit

Permalink
enable set https ip addrs
Browse files Browse the repository at this point in the history
  • Loading branch information
philchia committed Jul 28, 2019
1 parent ef4758d commit f096ec8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net"
"net/url"
"strings"
)

func getLocalIP() string {
Expand All @@ -26,9 +27,17 @@ func toIP4(addr net.Addr) net.IP {
return nil
}

func httpurl(ip string) string {
if strings.HasPrefix(ip, "http://")||strings.HasPrefix(ip,"https://") {
return ip
}

return fmt.Sprintf("http://%s", ip)
}

func notificationURL(conf *Conf, notifications string) string {
return fmt.Sprintf("http://%s/notifications/v2?appId=%s&cluster=%s&notifications=%s",
conf.IP,
return fmt.Sprintf("%s/notifications/v2?appId=%s&cluster=%s&notifications=%s",
httpurl(conf.IP),
url.QueryEscape(conf.AppID),
url.QueryEscape(conf.Cluster),
url.QueryEscape(notifications))
Expand Down
2 changes: 1 addition & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ func (r *httprequester) request(url string) ([]byte, error) {
}

// Diacard all body if status code is not 200
io.Copy(ioutil.Discard, resp.Body)
_, _ = io.Copy(ioutil.Discard, resp.Body)
return nil, nil
}

0 comments on commit f096ec8

Please sign in to comment.