package main import ( "html/template" "net/http" ) var templateWatchFiles = []string{ "templates/base.html", "templates/watch.html" } var templateWatch = template.Must(template.ParseFiles(templateWatchFiles...)) /* render template */ type WatchTemplateData struct { Id string } func renderWatchTemplate(w http.ResponseWriter, id string) { if debug { reloadTemplate(&templateWatch, templateWatchFiles...) } err := templateWatch.Execute(w, WatchTemplateData{ Id: id, }) if err != nil { templateError(err, w) } } /* routes */ func setupRoutesWatch() { http.HandleFunc("/watch", func(w http.ResponseWriter, r *http.Request) { id := r.URL.Query().Get("v") renderWatchTemplate(w, id) }) }