diff options
author | Tim Keller <tjkeller.xyz> | 2025-05-24 12:52:32 -0500 |
---|---|---|
committer | Tim Keller <tjkeller.xyz> | 2025-05-24 12:52:32 -0500 |
commit | bcf66d92d664dd707937ae866830a6bee0751745 (patch) | |
tree | 5c1f7ecc037b53b434befe71509cc3009beaf3d7 /watch.go | |
parent | 6b0385c495b246859d27bfa75e1bd4dfa45c2be2 (diff) | |
download | mintube-master.tar.xz mintube-master.zip |
Diffstat (limited to 'watch.go')
-rw-r--r-- | watch.go | 34 |
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) + }) +} |