add podcast page

This commit is contained in:
2026-02-13 17:14:02 +03:00
parent e4c22dbe47
commit 9c7fa50fcd
2 changed files with 95 additions and 0 deletions

28
main.go
View File

@@ -357,6 +357,34 @@ func main() {
sendJSON(w, podcasts, 200)
})
mux.HandleFunc("GET /podcasts/{id}", func(w http.ResponseWriter, r *http.Request) {
id, err := strconv.Atoi(r.PathValue("id"))
if err != nil {
http.Error(w, err.Error(), 404)
return
}
podcast, err := getPodcastById(db, int64(id))
if err != nil {
http.Error(w, err.Error(), 404)
return
}
episodes, err := getPodcastEpisodes(db, podcast.ID)
if err != nil {
http.Error(w, err.Error(), 404)
return
}
tmpl.ExecuteTemplate(w, "podcast.html", struct {
Podcast *Podcast
Episodes []*Episode
}{
Podcast: podcast,
Episodes: episodes,
})
})
mux.HandleFunc("POST /podcasts", func(w http.ResponseWriter, r *http.Request) {
var body struct {
Feed string `json:"feed"`