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

@ -87,9 +87,9 @@ gulp.task('gzip', ['html', 'css', 'js', 'fonts'], function() {
function bindata(cb) {
if (argv.production) {
exec('go-bindata -nomemcopy -nocompress -pkg server -o ../server/bindata.go dist/gz/...', cb);
exec('go-bindata -nomemcopy -nocompress -pkg server -o ../server/bindata.go -prefix "dist/gz" dist/gz/...', cb);
} else {
exec('go-bindata -debug -pkg server -o ../server/bindata.go dist/...', cb);
exec('go-bindata -debug -pkg server -o ../server/bindata.go -prefix "dist/gz" dist/...', cb);
}
}

File diff suppressed because one or more lines are too long

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) {