func Index() http.HandlerFunc { indexfile := bundle.ReadFile("assets/index.html") indexpage := template.Must(template.New("index").Parse(string(indexfile))) namePattern := regexp.MustCompile("^/(?P<name>\\w+)") return LogRequest(func(w http.ResponseWriter, r *http.Request) { params := ExtractNamed(r.URL.Path, namePattern) if len(params["name"]) == 0 { params["name"] = DEFAULT_GRAPH_NAME } indexpage.Execute(w, params["name"]) }) // TODO Consider building the JS into the HTML, and removing Script() }
func Script() http.HandlerFunc { scriptfile := bytes.NewReader(bundle.ReadFile("assets/script.js")) return LogRequest(func(w http.ResponseWriter, r *http.Request) { http.ServeContent(w, r, "script.js", time.Now(), scriptfile) }) }