added head requests to sitemaps
This commit is contained in:
14
main.go
14
main.go
@@ -1059,8 +1059,14 @@ func getSiteMapIndex(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
c.Data(http.StatusOK, "application/xml", res)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getSiteMap(c *gin.Context) {
|
func getSiteMap(c *gin.Context) {
|
||||||
if c.Param("id") == "" {
|
if c.Param("id") == "" {
|
||||||
@@ -1085,8 +1091,14 @@ func getSiteMap(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
c.Data(http.StatusOK, "application/xml", res)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
/player/<id> GET player details (last 10 matches)
|
/player/<id> GET player details (last 10 matches)
|
||||||
@@ -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