diff --git a/main.go b/main.go index 34c5bca..4132faf 100644 --- a/main.go +++ b/main.go @@ -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...")