From a565f348427bfe35fcbee631936535d0734d2034 Mon Sep 17 00:00:00 2001 From: Adhityaa Date: Sun, 3 Jun 2018 16:42:37 +0530 Subject: [PATCH] router_static.go: use a common path string --- api/router_static.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/api/router_static.go b/api/router_static.go index e7dc151..ba00230 100644 --- a/api/router_static.go +++ b/api/router_static.go @@ -72,23 +72,21 @@ func initStaticRouter(router *mux.Router) error { t, err := template.New(page).Delims("<<<", ">>>").Parse(string(contents)) if err != nil { - logger.Errorf("cannot parse %s.html template: %v", page, err) + logger.Errorf("cannot parse /%s template: %v", page, err) return err } var buf bytes.Buffer t.Execute(&buf, &staticHtmlPlugs{CdnPrefix: os.Getenv("CDN_PREFIX")}) - html[page] = buf.String() + html["/" + page] = buf.String() } for _, page := range pages { - router.HandleFunc("/"+page, func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, html[page]) + router.HandleFunc("/" + page, func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, html[r.URL.Path]) }) } - router.HandleFunc("/", redirectLogin).Methods("GET") - return nil }