cpolis/cmd/ui/rss.go

25 lines
499 B
Go

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