From 7e9713b35ef662edbfdfdb9dd6c688b5ca759657 Mon Sep 17 00:00:00 2001 From: Adhityaa Date: Sun, 3 Jun 2018 20:18:30 +0530 Subject: [PATCH] router_static.go: use a prefix variable --- api/router_static.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/router_static.go b/api/router_static.go index b97a6e9..38cd68c 100644 --- a/api/router_static.go +++ b/api/router_static.go @@ -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]) })