mirror of
https://github.com/rancher/steve.git
synced 2025-05-03 05:26:25 +00:00
Add log message to log the error from http client (#596)
This commit is contained in:
parent
53f2165aee
commit
4101ed2f30
@ -1,7 +1,6 @@
|
|||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -13,17 +12,6 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
insecureClient = &http.Client{
|
|
||||||
Transport: &http.Transport{
|
|
||||||
Proxy: http.ProxyFromEnvironment,
|
|
||||||
TLSClientConfig: &tls.Config{
|
|
||||||
InsecureSkipVerify: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultPath = "./ui"
|
defaultPath = "./ui"
|
||||||
)
|
)
|
||||||
@ -158,7 +146,10 @@ func (u *Handler) IndexFileOnNotFound() http.Handler {
|
|||||||
func (u *Handler) IndexFile() http.Handler {
|
func (u *Handler) IndexFile() http.Handler {
|
||||||
return u.indexMiddleware(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
return u.indexMiddleware(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
if path, isURL := u.path(); isURL {
|
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 {
|
} else {
|
||||||
http.ServeFile(rw, req, filepath.Join(path, "index.html"))
|
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 {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user