router_static.go: use a prefix variable

This commit is contained in:
Adhityaa 2018-06-03 20:18:30 +05:30
parent dec05be7f8
commit 7e9713b35e

View File

@ -42,13 +42,13 @@ func initStaticRouter(router *mux.Router) error {
return err
}
prefix := ""
if dir == "js" {
asset[path] = "window.origin='" + os.Getenv("ORIGIN") + "';" + string(contents)
} else {
asset[path] = string(contents)
prefix = "window.origin='" + os.Getenv("ORIGIN") + "';"
}
logger.Debugf("routing %s", path)
asset[p] = prefix + string(contents);
router.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, asset[r.URL.Path])
})