aboutsummaryrefslogtreecommitdiff
path: root/backend/api/routes.go
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-08-26 08:53:24 +0300
committerArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-08-26 08:53:24 +0300
commitf1b7589b2936335957a6a1da1eea3d66233ad0ce (patch)
tree1975af217c190f5dbdb23b96015cef45206302d4 /backend/api/routes.go
parentdocs: profile improvement swagger (#51) (diff)
downloadlphub-f1b7589b2936335957a6a1da1eea3d66233ad0ce.tar.gz
lphub-f1b7589b2936335957a6a1da1eea3d66233ad0ce.tar.bz2
lphub-f1b7589b2936335957a6a1da1eea3d66233ad0ce.zip
refactor: reorganizing packages
Former-commit-id: 99410223654c2a5ffc15fdab6ec3e921b5410cba
Diffstat (limited to 'backend/api/routes.go')
-rw-r--r--backend/api/routes.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/backend/api/routes.go b/backend/api/routes.go
new file mode 100644
index 0000000..4dd8660
--- /dev/null
+++ b/backend/api/routes.go
@@ -0,0 +1,40 @@
1package api
2
3import (
4 "github.com/gin-gonic/gin"
5 "github.com/pektezol/leastportalshub/backend/handlers"
6 swaggerfiles "github.com/swaggo/files"
7 ginSwagger "github.com/swaggo/gin-swagger"
8)
9
10func InitRoutes(router *gin.Engine) {
11 api := router.Group("/api")
12 {
13 v1 := api.Group("/v1")
14 v1.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
15 v1.GET("/", func(c *gin.Context) {
16 c.File("docs/index.html")
17 })
18 v1.GET("/token", handlers.GetCookie)
19 v1.DELETE("/token", handlers.DeleteCookie)
20 v1.GET("/home", CheckAuth, handlers.Home)
21 v1.GET("/login", handlers.Login)
22 v1.GET("/profile", CheckAuth, handlers.Profile)
23 v1.PUT("/profile", CheckAuth, handlers.UpdateCountryCode)
24 v1.POST("/profile", CheckAuth, handlers.UpdateUser)
25 v1.GET("/users/:id", CheckAuth, handlers.FetchUser)
26 v1.GET("/demos", handlers.DownloadDemoWithID)
27 v1.GET("/maps/:id/summary", handlers.FetchMapSummary)
28 v1.POST("/maps/:id/summary", CheckAuth, handlers.CreateMapSummary)
29 v1.PUT("/maps/:id/summary", CheckAuth, handlers.EditMapSummary)
30 v1.DELETE("/maps/:id/summary", CheckAuth, handlers.DeleteMapSummary)
31 v1.PUT("/maps/:id/image", CheckAuth, handlers.EditMapImage)
32 v1.GET("/maps/:id/leaderboards", handlers.FetchMapLeaderboards)
33 v1.POST("/maps/:id/record", CheckAuth, handlers.CreateRecordWithDemo)
34 v1.GET("/rankings", handlers.Rankings)
35 v1.GET("/search", handlers.SearchWithQuery)
36 v1.GET("/games", handlers.FetchGames)
37 v1.GET("/games/:id", handlers.FetchChapters)
38 v1.GET("/chapters/:id", handlers.FetchChapterMaps)
39 }
40}