From a5d31cb2395309d730c9f7911d4b7783adf07a95 Mon Sep 17 00:00:00 2001 From: Johannes 'fish' Ziemke Date: Tue, 19 Mar 2013 16:11:55 +0100 Subject: [PATCH] Use constants for blob bucket keys. --- web/blob/blob.go | 9 +++++++-- web/status.go | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/web/blob/blob.go b/web/blob/blob.go index 479cba5bb..27907ad2d 100644 --- a/web/blob/blob.go +++ b/web/blob/blob.go @@ -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) } diff --git a/web/status.go b/web/status.go index c30cd4268..7f6bf6396 100644 --- a/web/status.go +++ b/web/status.go @@ -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) }