Endpoints reorganised a little. Handlers for assets are moved out of Handlers struct as a self-sustained funcs.
This commit is contained in:
parent
183eb74ada
commit
e856a4b930
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user