bump(github.com/google/cadvisor): 27e1acbb4ef0fe1889208b21f8f4a6d0863e02f6

This commit is contained in:
Seth Jennings
2017-08-14 12:53:25 -05:00
parent 89cd583ec3
commit fa71aac011
20 changed files with 348 additions and 171 deletions

View File

@@ -22,6 +22,8 @@ import (
"net/http"
"net/url"
"path"
"github.com/golang/glog"
)
const StaticResource = "/static/"
@@ -47,16 +49,18 @@ var staticFiles = map[string][]byte{
"jquery-1.10.2.min.js": jqueryJs,
}
func HandleRequest(w http.ResponseWriter, u *url.URL) error {
func HandleRequest(w http.ResponseWriter, u *url.URL) {
if len(u.Path) <= len(StaticResource) {
return fmt.Errorf("unknown static resource %q", u.Path)
http.Error(w, fmt.Sprintf("unknown static resource %q", u.Path), http.StatusNotFound)
return
}
// Get the static content if it exists.
resource := u.Path[len(StaticResource):]
content, ok := staticFiles[resource]
if !ok {
return fmt.Errorf("unknown static resource %q", resource)
http.Error(w, fmt.Sprintf("unknown static resource %q", u.Path), http.StatusNotFound)
return
}
// Set Content-Type if we were able to detect it.
@@ -65,6 +69,7 @@ func HandleRequest(w http.ResponseWriter, u *url.URL) error {
w.Header().Set("Content-Type", contentType)
}
_, err := w.Write(content)
return err
if _, err := w.Write(content); err != nil {
glog.Errorf("Failed to write response: %v", err)
}
}