Skip to content

Commit 9dc48c7

Browse files
authored
Add log message to log the error from http client (#599)
1 parent f0aee3b commit 9dc48c7

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

pkg/ui/handler.go

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package ui
22

33
import (
4-
"crypto/tls"
54
"io"
65
"io/ioutil"
76
"net/http"
@@ -13,17 +12,6 @@ import (
1312
"github.com/sirupsen/logrus"
1413
)
1514

16-
var (
17-
insecureClient = &http.Client{
18-
Transport: &http.Transport{
19-
Proxy: http.ProxyFromEnvironment,
20-
TLSClientConfig: &tls.Config{
21-
InsecureSkipVerify: true,
22-
},
23-
},
24-
}
25-
)
26-
2715
const (
2816
defaultPath = "./ui"
2917
)
@@ -158,15 +146,23 @@ func (u *Handler) IndexFileOnNotFound() http.Handler {
158146
func (u *Handler) IndexFile() http.Handler {
159147
return u.indexMiddleware(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
160148
if path, isURL := u.path(); isURL {
161-
_ = serveIndex(rw, path)
149+
err := serveIndex(rw, path)
150+
if err != nil {
151+
logrus.Errorf("failed to download %s: %v", path, err)
152+
}
162153
} else {
163154
http.ServeFile(rw, req, filepath.Join(path, "index.html"))
164155
}
165156
}))
166157
}
167158

168159
func serveIndex(resp io.Writer, url string) error {
169-
r, err := insecureClient.Get(url)
160+
client := &http.Client{
161+
Transport: &http.Transport{
162+
Proxy: http.ProxyFromEnvironment,
163+
},
164+
}
165+
r, err := client.Get(url)
170166
if err != nil {
171167
return err
172168
}

0 commit comments

Comments
 (0)