|
|
|
@ -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) |
|
|
|
|
} |
|
|
|
|