diff --git a/cmd/dwelling-home/main.go b/cmd/dwelling-home/main.go index 4c9ed32..a61e75a 100644 --- a/cmd/dwelling-home/main.go +++ b/cmd/dwelling-home/main.go @@ -72,7 +72,11 @@ func main() { srv.SetNotFoundHandler(http.NotFound) - srv.ServeStatic("/assets/*filepath", hand.AssetsFS()) + srv.ServeStatic("/assets/*filepath", http.AssetsFS()) + srv.GET("/robots.txt", http.RobotsTxt) + srv.GET("/rss.xml", hand.RSS) + srv.GET("/sitemap.xml", http.SitemapXml) + srv.GET("/", hand.Index) srv.GET("/stuff", hand.Stuff) srv.GET("/stuff/article/*filepath", hand.Article) @@ -82,10 +86,6 @@ func main() { srv.GET("/guestbook", hand.Guestbook) srv.GET("/guestbook/admin", hand.GuestbookAdmin) - srv.GET("/robots.txt", hand.Robots) - srv.GET("/rss.xml", hand.RSS) - srv.GET("/sitemap.xml", hand.Sitemap) - captchaApi := http.NewCaptchaApiHandlers(*captchaExpiry) srv.POST("/api/captcha/", captchaApi.New) diff --git a/internal/http/handlers.go b/internal/http/handlers.go index b42d6a5..35ddc0b 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -38,10 +38,6 @@ func (h *Handlers) CloseDB() { h.guestbookDB.Close() } -func (h *Handlers) AssetsFS() http.FileSystem { - return web.Assets() -} - func (h *Handlers) Index(w http.ResponseWriter, r *http.Request) { web.Index("", w) } @@ -160,12 +156,16 @@ func (h *Handlers) RSS(w http.ResponseWriter, r *http.Request) { web.RSS(r.URL.Scheme+"://"+r.Host, "Arav", posts, r, w) } -func (h *Handlers) Robots(w http.ResponseWriter, r *http.Request) { +func AssetsFS() http.FileSystem { + return web.Assets() +} + +func RobotsTxt(w http.ResponseWriter, r *http.Request) { data, _ := web.AssetsGetFile("robots.txt") w.Write(data) } -func (h *Handlers) Sitemap(w http.ResponseWriter, r *http.Request) { +func SitemapXml(w http.ResponseWriter, r *http.Request) { data, _ := web.AssetsGetFile("sitemap.xml") w.Write(data) }