mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -08:00
Use constants for blob bucket keys.
This commit is contained in:
parent
59f8ba9121
commit
a5d31cb239
|
@ -8,6 +8,11 @@ import (
|
|||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
TemplateFiles = "templates"
|
||||
StaticFiles = "static"
|
||||
)
|
||||
|
||||
func GetFile(bucket string, name string) ([]byte, error) {
|
||||
reader := bytes.NewReader(files[bucket][name])
|
||||
gz, err := gzip.NewReader(reader)
|
||||
|
@ -30,7 +35,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
name = "index.html"
|
||||
}
|
||||
|
||||
file, err := GetFile("static", name)
|
||||
file, err := GetFile(StaticFiles, name)
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
log.Printf("Could not get file: %s", err)
|
||||
|
@ -38,6 +43,6 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", types["static"][name])
|
||||
w.Header().Set("Content-Type", types[StaticFiles][name])
|
||||
w.Write(file)
|
||||
}
|
||||
|
|
|
@ -40,11 +40,11 @@ func (h *StatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
Status: "TODO: add status information here",
|
||||
TargetPools: h.appState.TargetManager.Pools(),
|
||||
}
|
||||
template_file, err := blob.GetFile("templates", "status.html")
|
||||
templateFile, err := blob.GetFile(blob.TemplateFiles, "status.html")
|
||||
if err != nil {
|
||||
log.Fatalf("Could not read template: %s", err)
|
||||
}
|
||||
|
||||
t, _ := template.New("status").Parse(string(template_file))
|
||||
t, _ := template.New("status").Parse(string(templateFile))
|
||||
t.Execute(w, status)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue