|
|
@ -8,6 +8,11 @@ import (
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
|
|
TemplateFiles = "templates"
|
|
|
|
|
|
|
|
StaticFiles = "static"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func GetFile(bucket string, name string) ([]byte, error) {
|
|
|
|
func GetFile(bucket string, name string) ([]byte, error) {
|
|
|
|
reader := bytes.NewReader(files[bucket][name])
|
|
|
|
reader := bytes.NewReader(files[bucket][name])
|
|
|
|
gz, err := gzip.NewReader(reader)
|
|
|
|
gz, err := gzip.NewReader(reader)
|
|
|
@ -30,7 +35,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
name = "index.html"
|
|
|
|
name = "index.html"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
file, err := GetFile("static", name)
|
|
|
|
file, err := GetFile(StaticFiles, name)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if err != io.EOF {
|
|
|
|
if err != io.EOF {
|
|
|
|
log.Printf("Could not get file: %s", err)
|
|
|
|
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)
|
|
|
|
w.WriteHeader(http.StatusNotFound)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
w.Header().Set("Content-Type", types["static"][name])
|
|
|
|
w.Header().Set("Content-Type", types[StaticFiles][name])
|
|
|
|
w.Write(file)
|
|
|
|
w.Write(file)
|
|
|
|
}
|
|
|
|
}
|
|
|
|