add podcast page
This commit is contained in:
28
main.go
28
main.go
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user