diff --git a/api/rss.go b/api/rss.go index c5937f1..6db9e7e 100644 --- a/api/rss.go +++ b/api/rss.go @@ -1,7 +1,6 @@ package api import ( - "fmt" "net/http" "os" "strings" @@ -13,11 +12,6 @@ import ( ) func RSSFeedHandler(c echo.Context) error { - feed := &feeds.Feed{ - Title: "Goth Stack Sample Blog", - Link: &feeds.Link{Href: "https://goth-stack.fly.dev/"}, - } - files, err := os.ReadDir("./content/") protocol := "http" @@ -25,6 +19,11 @@ func RSSFeedHandler(c echo.Context) error { protocol = "https" } + feed := &feeds.Feed{ + Title: "GOTH Stack Demo Blog", + Link: &feeds.Link{Href: protocol + "://" + c.Request().Host + "/api/rss"}, + } + if err != nil { http.Error(c.Response().Writer, "There was an issue finding posts!", http.StatusInternalServerError) return nil @@ -47,6 +46,5 @@ func RSSFeedHandler(c echo.Context) error { } rss, _ := feed.ToRss() - fmt.Println("RSS:", rss) - return c.String(http.StatusOK, rss) + return c.Blob(http.StatusOK, "application/rss+xml", []byte(rss)) }