-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.go
More file actions
56 lines (46 loc) · 1.56 KB
/
router.go
File metadata and controls
56 lines (46 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package router
import (
"net/http"
"rankland/api"
"rankland/middleware"
"github.com/gin-gonic/gin"
)
func Group(r *gin.Engine) {
r.GET("/", func(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "成功",
"data": "hello word",
})
})
r.GET("/statistics", api.GetStatistics)
r.GET("/sitemap/ranklist.xml", api.SitemapRanklistIndex)
r.GET("/sitemap/ranklist_vol_:volName", api.SitemapRanklistVol)
rank(r.Group("/rank"))
ranking(r.Group("/ranking"))
file(r.Group("/file"))
}
func rank(rg *gin.RouterGroup) {
rg.POST("", middleware.WriteHeader(), api.CreateRank)
rg.GET("/:key", api.GetRank)
rg.PUT("/:id", middleware.WriteHeader(), api.UpdateRank)
rg.GET("/search", api.SearchRank)
g := rg.Group("/group")
g.POST("", middleware.WriteHeader(), api.CreateRankGroup)
g.GET("/:key", api.GetRankGroup)
g.PUT("/:id", middleware.WriteHeader(), api.UpdateRankGroup)
}
func ranking(rg *gin.RouterGroup) {
rg.GET("/config/:key", api.GetRankingConfig)
rg.POST("/config", middleware.WriteHeader(), api.CreateRankingConfig)
rg.PUT("/config/:id", middleware.WriteHeader(), api.UpdateRankingConfig)
rg.DELETE("/config/:id", middleware.WriteHeader(), api.DeleteContest)
rg.GET("/:id", api.GetRankingByConfigID)
rg.GET("/record/:id", api.GetRecordByConfigID)
rg.POST("/record/:id", middleware.WriteHeader(), api.SetRecord) // 比赛提交记录
rg.DELETE("/record/:id", middleware.WriteHeader(), api.ClearRecord)
}
func file(rg *gin.RouterGroup) {
rg.POST("/upload", middleware.WriteHeader(), api.Upload)
rg.GET("/download", api.Download)
}