I would like to be able to get an XML content without having to create a sitemap.xml.gz.
In my app, I plan to generate and serve a sitemap on the fly when the client requests one. The reason is that the content changes frequently and I would rather make the sitemap dynamic based on the current database.
An implementation looks something like this.
func SitemapHandler(w http.ResponseWriter, r *http.Request) {
sm := stm.NewSitemap()
sm.Create()
sm.Add(stm.URL{
"loc": "...",
})
...
xml := sm.XMLContent()
w.Header().Set("Content-Type", "application/xml")
w.Write(xml)
}
Basically, it'd be great if Sitemap had a method like XMLContent() that returns a raw XML content of the sitemap. I will open a PR.
I would like to be able to get an XML content without having to create a
sitemap.xml.gz
.In my app, I plan to generate and serve a sitemap on the fly when the client requests one. The reason is that the content changes frequently and I would rather make the sitemap dynamic based on the current database.
An implementation looks something like this.
Basically, it'd be great if
Sitemap
had a method likeXMLContent()
that returns a raw XML content of the sitemap. I will open a PR.