fix: sitemap at root

This commit is contained in:
HeshamTB 2023-09-13 18:23:15 +03:00
parent 98c7ee4b61
commit 8fd3811a72

15
main.go
View File

@ -126,7 +126,6 @@ func init() {
log.Println("[ init ] Starting...") log.Println("[ init ] Starting...")
templates = template.Must(template.ParseFS(TemplatesFS , "templates/*.html")) templates = template.Must(template.ParseFS(TemplatesFS , "templates/*.html"))
log.Println("[ init ] Templates Loaded") log.Println("[ init ] Templates Loaded")
log.Println(AssetsFS.ReadDir("assets"))
} }
@ -149,6 +148,20 @@ func main() {
}, },
) )
handler.HandleFunc(
"/sitemap.txt",
func(w http.ResponseWriter, r *http.Request) {
sitemapFile, err := AssetsFS.ReadFile("assets/sitemap.txt")
if err != nil {
log.Println(err.Error())
w.WriteHeader(500)
return
}
w.Write(sitemapFile)
},
)
handler.HandleFunc( handler.HandleFunc(
"/download", "/download",
func(w http.ResponseWriter, r *http.Request) { func(w http.ResponseWriter, r *http.Request) {