package routes import ( "github.com/gin-gonic/gin" "github.com/qit-team/snow-core/http/middleware" "qteam/app/http/controllers" "qteam/app/http/controllers/backend" "qteam/app/http/middlewares" "qteam/app/http/trace" "qteam/app/utils" "qteam/config" ) func RegisterAdminRoute(router *gin.Engine) { router.Use(middlewares.ServerRecovery(), middleware.GenRequestId, middleware.GenContextKit, middleware.AccessLog()) router.NoRoute(controllers.Error404) if len(config.GetConf().SkyWalkingOapServer) > 0 && config.IsEnvEqual(config.ProdEnv) { err := trace.InitTracer(config.GetConf().ServiceName, config.GetConf().SkyWalkingOapServer) if err != nil { utils.Log(nil, "InitTracer", err.Error()) } else { router.Use(middlewares.Trace()) } } admin := router.Group("/admin") { api := admin.Group("/api") { api.POST("/userList", backend.UserList) } } v1 := router.Group("/admin/api/v1") { products := v1.Group("/product") products.POST("/create", middlewares.ValidateRequest(), backend.ProductCreateHandler) products.GET("/query", backend.ProductQueryHandler) products.PUT("/update", middlewares.ValidateRequest(), backend.ProductUpdateHandler) products.DELETE("/delete", backend.ProductDeleteHandler) } }