Commit d3cb1bd4 authored by Lukas Matt's avatar Lukas Matt

Fallback to http if FetchJson fails with ssl

parent 2b8153b7
......@@ -69,7 +69,11 @@ func push(host, endpoint, proto, contentType string, body io.Reader) error {
}
func FetchJson(method, url string, body io.Reader, result interface{}) error {
req, err := http.NewRequest(method, url, body)
var proto string
if !strings.HasPrefix(url, "http") {
proto = "https://"
}
req, err := http.NewRequest(method, proto + url, body)
if err != nil {
return err
}
......@@ -80,6 +84,9 @@ func FetchJson(method, url string, body io.Reader, result interface{}) error {
}
resp, err := client.Do(req)
if err != nil {
if !strings.HasPrefix(url, "http") {
return FetchJson(method, "http://" + url, body, result)
}
return err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment