aboutsummaryrefslogtreecommitdiff
path: root/watch.go
diff options
context:
space:
mode:
Diffstat (limited to 'watch.go')
-rw-r--r--watch.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/watch.go b/watch.go
new file mode 100644
index 0000000..8352e62
--- /dev/null
+++ b/watch.go
@@ -0,0 +1,34 @@
+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)
+ })
+}