package main import ( "html" "net/http" "strings" "git.32bit.cafe/yequari/rss-gen/rss" ) func (app *application) home(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { http.NotFound(w, r) return } app.render(w, http.StatusOK, "home.tmpl.html", nil) } func (app *application) generateRss(w http.ResponseWriter, r *http.Request) { q := r.URL.Query() siteName := q.Get("site-name") siteUrl := q.Get("site-url") siteDesc := q.Get("site-description") pageUrls := q.Get("page-urls") pages := strings.Split(pageUrls, "\n") for i := range pages { pages[i] = strings.TrimSpace(pages[i]) } feed, err := rss.GenerateRss(siteUrl, siteName, siteDesc, pages...) if err != nil { app.infoLog.Printf("Error generating feed: %s\n", err.Error()) } for _, line := range strings.Split(feed, "\n") { w.Write([]byte(html.EscapeString(line) + "\n")) } }