diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-22 23:58:26 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-22 23:58:26 +0300 |
| commit | 9cd44de9be62e1291f84763bc029f995301e1e03 (patch) | |
| tree | 5b4b8bc6d7a89173373fbb32c5a8c5013f8c9d82 /backend/api/routes.go | |
| parent | feat: map search (#78) (diff) | |
| download | lphub-9cd44de9be62e1291f84763bc029f995301e1e03.tar.gz lphub-9cd44de9be62e1291f84763bc029f995301e1e03.tar.bz2 lphub-9cd44de9be62e1291f84763bc029f995301e1e03.zip | |
feat: discussions (#59)
Former-commit-id: ac6ac59367650b6a37650f5aec0587c6ce4d3dd1
Diffstat (limited to 'backend/api/routes.go')
| -rw-r--r-- | backend/api/routes.go | 89 |
1 files changed, 63 insertions, 26 deletions
diff --git a/backend/api/routes.go b/backend/api/routes.go index fd3b8cc..339dc73 100644 --- a/backend/api/routes.go +++ b/backend/api/routes.go | |||
| @@ -7,35 +7,72 @@ import ( | |||
| 7 | ginSwagger "github.com/swaggo/gin-swagger" | 7 | ginSwagger "github.com/swaggo/gin-swagger" |
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | const ( | ||
| 11 | apiPath string = "/api" | ||
| 12 | v1Path string = "/v1" | ||
| 13 | swaggerPath string = "/swagger/*any" | ||
| 14 | indexPath string = "/" | ||
| 15 | tokenPath string = "/token" | ||
| 16 | loginPath string = "/login" | ||
| 17 | profilePath string = "/profile" | ||
| 18 | usersPath string = "/users/:userid" | ||
| 19 | demosPath string = "/demos" | ||
| 20 | mapSummaryPath string = "/maps/:mapid/summary" | ||
| 21 | mapImagePath string = "/maps/:mapid/image" | ||
| 22 | mapLeaderboardsPath string = "/maps/:mapid/leaderboards" | ||
| 23 | mapRecordPath string = "/maps/:mapid/record" | ||
| 24 | mapDiscussionsPath string = "/maps/:mapid/discussions" | ||
| 25 | mapDiscussionIDPath string = "/maps/:mapid/discussions/:discussionid" | ||
| 26 | rankingsPath string = "/rankings" | ||
| 27 | searchPath string = "/search" | ||
| 28 | gamesPath string = "/games" | ||
| 29 | chaptersPath string = "/games/:gameid" | ||
| 30 | chapterMapsPath string = "/chapters/:chapterid" | ||
| 31 | scoreLogsPath string = "/logs/score" | ||
| 32 | modLogsPath string = "/logs/mod" | ||
| 33 | ) | ||
| 34 | |||
| 10 | func InitRoutes(router *gin.Engine) { | 35 | func InitRoutes(router *gin.Engine) { |
| 11 | api := router.Group("/api") | 36 | api := router.Group(apiPath) |
| 12 | { | 37 | { |
| 13 | v1 := api.Group("/v1") | 38 | v1 := api.Group(v1Path) |
| 14 | v1.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) | 39 | // Swagger |
| 15 | v1.GET("/", func(c *gin.Context) { | 40 | v1.GET(swaggerPath, ginSwagger.WrapHandler(swaggerfiles.Handler)) |
| 41 | v1.GET(indexPath, func(c *gin.Context) { | ||
| 16 | c.File("docs/index.html") | 42 | c.File("docs/index.html") |
| 17 | }) | 43 | }) |
| 18 | v1.GET("/token", handlers.GetCookie) | 44 | // Tokens, login |
| 19 | v1.DELETE("/token", handlers.DeleteCookie) | 45 | v1.GET(tokenPath, handlers.GetCookie) |
| 20 | v1.GET("/login", handlers.Login) | 46 | v1.DELETE(tokenPath, handlers.DeleteCookie) |
| 21 | v1.GET("/profile", CheckAuth, handlers.Profile) | 47 | v1.GET(loginPath, handlers.Login) |
| 22 | v1.PUT("/profile", CheckAuth, handlers.UpdateCountryCode) | 48 | // Users, profiles |
| 23 | v1.POST("/profile", CheckAuth, handlers.UpdateUser) | 49 | v1.GET(profilePath, CheckAuth, handlers.Profile) |
| 24 | v1.GET("/users/:id", CheckAuth, handlers.FetchUser) | 50 | v1.PUT(profilePath, CheckAuth, handlers.UpdateCountryCode) |
| 25 | v1.GET("/demos", handlers.DownloadDemoWithID) | 51 | v1.POST(profilePath, CheckAuth, handlers.UpdateUser) |
| 26 | v1.GET("/maps/:id/summary", handlers.FetchMapSummary) | 52 | v1.GET(usersPath, CheckAuth, handlers.FetchUser) |
| 27 | v1.POST("/maps/:id/summary", CheckAuth, handlers.CreateMapSummary) | 53 | // Maps |
| 28 | v1.PUT("/maps/:id/summary", CheckAuth, handlers.EditMapSummary) | 54 | v1.GET(mapSummaryPath, handlers.FetchMapSummary) |
| 29 | v1.DELETE("/maps/:id/summary", CheckAuth, handlers.DeleteMapSummary) | 55 | v1.POST(mapSummaryPath, CheckAuth, handlers.CreateMapSummary) |
| 30 | v1.PUT("/maps/:id/image", CheckAuth, handlers.EditMapImage) | 56 | v1.PUT(mapSummaryPath, CheckAuth, handlers.EditMapSummary) |
| 31 | v1.GET("/maps/:id/leaderboards", handlers.FetchMapLeaderboards) | 57 | v1.DELETE(mapSummaryPath, CheckAuth, handlers.DeleteMapSummary) |
| 32 | v1.POST("/maps/:id/record", CheckAuth, handlers.CreateRecordWithDemo) | 58 | v1.PUT(mapImagePath, CheckAuth, handlers.EditMapImage) |
| 33 | v1.GET("/rankings", handlers.Rankings) | 59 | v1.GET(mapLeaderboardsPath, handlers.FetchMapLeaderboards) |
| 34 | v1.GET("/search", handlers.SearchWithQuery) | 60 | v1.POST(mapRecordPath, CheckAuth, handlers.CreateRecordWithDemo) |
| 35 | v1.GET("/games", handlers.FetchGames) | 61 | v1.GET(demosPath, handlers.DownloadDemoWithID) |
| 36 | v1.GET("/games/:id", handlers.FetchChapters) | 62 | v1.GET(mapDiscussionsPath, handlers.FetchMapDiscussions) |
| 37 | v1.GET("/chapters/:id", handlers.FetchChapterMaps) | 63 | v1.GET(mapDiscussionIDPath, handlers.FetchMapDiscussion) |
| 38 | v1.GET("/logs/score", handlers.ScoreLogs) | 64 | v1.POST(mapDiscussionsPath, CheckAuth, handlers.CreateMapDiscussion) |
| 39 | v1.GET("/logs/mod", CheckAuth, handlers.ModLogs) | 65 | v1.PUT(mapDiscussionIDPath, CheckAuth, handlers.EditMapDiscussion) |
| 66 | v1.DELETE(mapDiscussionIDPath, CheckAuth, handlers.DeleteMapDiscussion) | ||
| 67 | // Rankings, search | ||
| 68 | v1.GET(rankingsPath, handlers.Rankings) | ||
| 69 | v1.GET(searchPath, handlers.SearchWithQuery) | ||
| 70 | // Games, chapters, maps | ||
| 71 | v1.GET(gamesPath, handlers.FetchGames) | ||
| 72 | v1.GET(chaptersPath, handlers.FetchChapters) | ||
| 73 | v1.GET(chapterMapsPath, handlers.FetchChapterMaps) | ||
| 74 | // Logs | ||
| 75 | v1.GET(scoreLogsPath, handlers.ScoreLogs) | ||
| 76 | v1.GET(modLogsPath, CheckAuth, handlers.ModLogs) | ||
| 40 | } | 77 | } |
| 41 | } | 78 | } |