added head requests to sitemaps

This commit is contained in:
2023-03-04 00:22:17 +01:00
parent 5c3abbe463
commit 4a46e43ce7

18
main.go
View File

@@ -1059,7 +1059,13 @@ func getSiteMapIndex(c *gin.Context) {
return
}
c.Data(http.StatusOK, "application/xml", res)
if c.Request.Method == http.MethodHead {
c.Header("Content-Length", strconv.Itoa(len(res)))
c.Header("Content-Type", "application/xml")
c.Status(http.StatusOK)
} else {
c.Data(http.StatusOK, "application/xml", res)
}
}
func getSiteMap(c *gin.Context) {
@@ -1085,7 +1091,13 @@ func getSiteMap(c *gin.Context) {
return
}
c.Data(http.StatusOK, "application/xml", res)
if c.Request.Method == http.MethodHead {
c.Header("Content-Length", strconv.Itoa(len(res)))
c.Header("Content-Type", "application/xml")
c.Status(http.StatusOK)
} else {
c.Data(http.StatusOK, "application/xml", res)
}
}
/*
@@ -1253,7 +1265,9 @@ func main() {
r.GET("/matches", getMatches)
r.GET("/matches/next/:time", getMatches)
r.GET("/sitemap.xml", getSiteMapIndex)
r.HEAD("/sitemap.xml", getSiteMapIndex)
r.GET("/sitemap/:id", getSiteMap)
r.HEAD("/sitemap/:id", getSiteMap)
log.Info("Start listening...")