1
0
mirror of https://github.com/rancher/steve.git synced 2025-04-27 11:00:48 +00:00

Add log message to log the error from http client (#596)

This commit is contained in:
Sakala Venkata Krishna Rohit 2025-04-14 12:37:15 -07:00 committed by GitHub
parent 53f2165aee
commit 4101ed2f30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,6 @@
package ui
import (
"crypto/tls"
"io"
"io/ioutil"
"net/http"
@ -13,17 +12,6 @@ import (
"github.com/sirupsen/logrus"
)
var (
insecureClient = &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
)
const (
defaultPath = "./ui"
)
@ -158,7 +146,10 @@ func (u *Handler) IndexFileOnNotFound() http.Handler {
func (u *Handler) IndexFile() http.Handler {
return u.indexMiddleware(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
if path, isURL := u.path(); isURL {
_ = serveIndex(rw, path)
err := serveIndex(rw, path)
if err != nil {
logrus.Errorf("failed to download %s: %v", path, err)
}
} else {
http.ServeFile(rw, req, filepath.Join(path, "index.html"))
}
@ -166,7 +157,12 @@ func (u *Handler) IndexFile() http.Handler {
}
func serveIndex(resp io.Writer, url string) error {
r, err := insecureClient.Get(url)
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
},
}
r, err := client.Get(url)
if err != nil {
return err
}