Strip bindata path

This commit is contained in:
khlieng 2015-05-16 00:33:51 +02:00
parent 375ed94177
commit c7faa254c5
3 changed files with 81 additions and 85 deletions

View file

@ -22,12 +22,12 @@ var (
sessionLock sync.Mutex
files = []File{
File{"/bundle.js", "text/javascript"},
File{"/bundle.css", "text/css"},
File{"/font/fontello.eot", "application/vnd.ms-fontobject"},
File{"/font/fontello.svg", "image/svg+xml"},
File{"/font/fontello.ttf", "application/x-font-ttf"},
File{"/font/fontello.woff", "application/font-woff"},
File{"bundle.js", "text/javascript"},
File{"bundle.css", "text/css"},
File{"font/fontello.eot", "application/vnd.ms-fontobject"},
File{"font/fontello.svg", "image/svg+xml"},
File{"font/fontello.ttf", "application/x-font-ttf"},
File{"font/fontello.woff", "application/font-woff"},
}
upgrader = websocket.Upgrader{
@ -73,18 +73,18 @@ func upgradeWS(w http.ResponseWriter, r *http.Request) {
func serveFiles(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
serveFile("dist/gz/index.html.gz", "text/html", w, r)
serveFile("index.html.gz", "text/html", w, r)
return
}
for _, file := range files {
if strings.HasSuffix(r.URL.Path, file.Path) {
serveFile("dist/gz"+file.Path+".gz", file.ContentType, w, r)
serveFile(file.Path+".gz", file.ContentType, w, r)
return
}
}
serveFile("dist/gz/index.html.gz", "text/html", w, r)
serveFile("index.html.gz", "text/html", w, r)
}
func serveFile(path, contentType string, w http.ResponseWriter, r *http.Request) {