package routers import ( "fmt" "bsm/full/module/base/logs/internal/logic/hello" "bsm/full/module/base/logs/internal/logic/log" "git.apinb.com/bsm-sdk/core/middleware" "github.com/gin-gonic/gin" ) func Register(srvKey string, engine *gin.Engine) { v1_key := fmt.Sprintf("/rest/%s", srvKey) registerAnonymous(v1_key, engine) registerAuth(v1_key, engine) } // registerAnonymous 不需要auth的接口 func registerAnonymous(v1_key string, engine *gin.Engine) { // Anonymous router. anonymous := engine.Group(v1_key) { anonymous.GET("/ping", hello.Ping) } } // registerAuth 需要JWT鉴权的业务接口 func registerAuth(v1_key string, engine *gin.Engine) { // Authorized router. auth := engine.Group(v1_key) auth.Use(middleware.JwtAuth(true)) { auth.POST("/create", log.Create) auth.POST("/fetch", log.LogFetch) auth.POST("/total", log.Total) } }