cpolis/cmd/ui/rss.go

25 lines
499 B
Go
Raw Normal View History

package ui
import (
"html/template"
"log"
"net/http"
2024-03-05 16:04:49 +01:00
"git.streifling.com/jason/rss"
)
2024-03-05 16:04:49 +01:00
func ShowRSS(f *rss.Feed) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
2024-03-05 16:04:49 +01:00
rss, err := f.ToXML()
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
2024-03-02 09:09:55 +01:00
files := []string{"web/templates/index.html", "web/templates/feed.rss"}
tmpl, err := template.ParseFiles(files...)
template.Must(tmpl, err).Execute(w, rss)
}
}