added head requests to sitemaps
This commit is contained in:
18
main.go
18
main.go
@@ -1059,7 +1059,13 @@ func getSiteMapIndex(c *gin.Context) {
|
|||||||
return
|
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) {
|
func getSiteMap(c *gin.Context) {
|
||||||
@@ -1085,7 +1091,13 @@ func getSiteMap(c *gin.Context) {
|
|||||||
return
|
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", getMatches)
|
||||||
r.GET("/matches/next/:time", getMatches)
|
r.GET("/matches/next/:time", getMatches)
|
||||||
r.GET("/sitemap.xml", getSiteMapIndex)
|
r.GET("/sitemap.xml", getSiteMapIndex)
|
||||||
|
r.HEAD("/sitemap.xml", getSiteMapIndex)
|
||||||
r.GET("/sitemap/:id", getSiteMap)
|
r.GET("/sitemap/:id", getSiteMap)
|
||||||
|
r.HEAD("/sitemap/:id", getSiteMap)
|
||||||
|
|
||||||
log.Info("Start listening...")
|
log.Info("Start listening...")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user