From f1b7589b2936335957a6a1da1eea3d66233ad0ce Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sat, 26 Aug 2023 08:53:24 +0300 Subject: refactor: reorganizing packages Former-commit-id: 99410223654c2a5ffc15fdab6ec3e921b5410cba --- backend/api/routes.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 backend/api/routes.go (limited to 'backend/api/routes.go') 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 @@ +package api + +import ( + "github.com/gin-gonic/gin" + "github.com/pektezol/leastportalshub/backend/handlers" + swaggerfiles "github.com/swaggo/files" + ginSwagger "github.com/swaggo/gin-swagger" +) + +func InitRoutes(router *gin.Engine) { + api := router.Group("/api") + { + v1 := api.Group("/v1") + v1.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) + v1.GET("/", func(c *gin.Context) { + c.File("docs/index.html") + }) + v1.GET("/token", handlers.GetCookie) + v1.DELETE("/token", handlers.DeleteCookie) + v1.GET("/home", CheckAuth, handlers.Home) + v1.GET("/login", handlers.Login) + v1.GET("/profile", CheckAuth, handlers.Profile) + v1.PUT("/profile", CheckAuth, handlers.UpdateCountryCode) + v1.POST("/profile", CheckAuth, handlers.UpdateUser) + v1.GET("/users/:id", CheckAuth, handlers.FetchUser) + v1.GET("/demos", handlers.DownloadDemoWithID) + v1.GET("/maps/:id/summary", handlers.FetchMapSummary) + v1.POST("/maps/:id/summary", CheckAuth, handlers.CreateMapSummary) + v1.PUT("/maps/:id/summary", CheckAuth, handlers.EditMapSummary) + v1.DELETE("/maps/:id/summary", CheckAuth, handlers.DeleteMapSummary) + v1.PUT("/maps/:id/image", CheckAuth, handlers.EditMapImage) + v1.GET("/maps/:id/leaderboards", handlers.FetchMapLeaderboards) + v1.POST("/maps/:id/record", CheckAuth, handlers.CreateRecordWithDemo) + v1.GET("/rankings", handlers.Rankings) + v1.GET("/search", handlers.SearchWithQuery) + v1.GET("/games", handlers.FetchGames) + v1.GET("/games/:id", handlers.FetchChapters) + v1.GET("/chapters/:id", handlers.FetchChapterMaps) + } +} -- cgit v1.2.3