mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
Split main func into multiples subfunctions
This commit is contained in:
+16
-4
@@ -22,13 +22,12 @@ func initJWT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initGin() {
|
func initBasicRoutes(r *gin.Engine) {
|
||||||
r := gin.Default()
|
|
||||||
r.SetTrustedProxies([]string{"localhost"})
|
|
||||||
|
|
||||||
r.POST("/login", internal.AuthMiddleware.LoginHandler)
|
r.POST("/login", internal.AuthMiddleware.LoginHandler)
|
||||||
r.GET("/ping", internal.Ping)
|
r.GET("/ping", internal.Ping)
|
||||||
|
}
|
||||||
|
|
||||||
|
func initArticlesRoutes(r *gin.Engine) {
|
||||||
articlesRouter := r.Group("/articles/")
|
articlesRouter := r.Group("/articles/")
|
||||||
articlesRouter.Use(internal.AuthMiddleware.MiddlewareFunc())
|
articlesRouter.Use(internal.AuthMiddleware.MiddlewareFunc())
|
||||||
|
|
||||||
@@ -36,6 +35,19 @@ func initGin() {
|
|||||||
articlesRouter.GET("/:id", internal.GetArticle)
|
articlesRouter.GET("/:id", internal.GetArticle)
|
||||||
articlesRouter.POST("/:id", internal.AddArticle)
|
articlesRouter.POST("/:id", internal.AddArticle)
|
||||||
articlesRouter.DELETE("/:id", internal.DeleteArticle)
|
articlesRouter.DELETE("/:id", internal.DeleteArticle)
|
||||||
|
}
|
||||||
|
|
||||||
|
func initGin() {
|
||||||
|
ginMode := os.Getenv("GIN_MODE")
|
||||||
|
if ginMode == "release" {
|
||||||
|
gin.SetMode(ginMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
r := gin.Default()
|
||||||
|
r.SetTrustedProxies([]string{"localhost"})
|
||||||
|
|
||||||
|
initBasicRoutes(r)
|
||||||
|
initArticlesRoutes(r)
|
||||||
|
|
||||||
r.Run(":" + os.Getenv("API_PORT"))
|
r.Run(":" + os.Getenv("API_PORT"))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user