cpolis/cmd/ui/rss.go

22 lines
458 B
Go

package ui
import (
"html/template"
"log"
"net/http"
"streifling.com/jason/cpolis/cmd/data"
)
func ShowRSS(feed *data.Feed) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
rss, err := feed.ToRss()
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
template.Must(template.ParseFiles("web/templates/index.html", "web/templates/feed.rss")).Execute(w, rss)
}
}