diff --git a/conf/config.yaml b/conf/config.yaml index 76825be..ecef3ef 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -2,6 +2,7 @@ lang: "zh-CN" app: web-client: 1 # 1:启用 0:禁用 register: false #是否开启注册 + show-swagger: 0 # 1:启用 0:禁用 admin: title: "RustDesk Api Admin" hello-file: "./conf/admin/hello.html" #优先使用file diff --git a/config/config.go b/config/config.go index 6190ae0..03a445b 100644 --- a/config/config.go +++ b/config/config.go @@ -14,8 +14,9 @@ const ( ) type App struct { - WebClient int `mapstructure:"web-client"` - Register bool `mapstructure:"register"` + WebClient int `mapstructure:"web-client"` + Register bool `mapstructure:"register"` + ShowSwagger int `mapstructure:"show-swagger"` } type Admin struct { Title string `mapstructure:"title"` diff --git a/http/router/admin.go b/http/router/admin.go index 4945ebe..92319a3 100644 --- a/http/router/admin.go +++ b/http/router/admin.go @@ -2,6 +2,7 @@ package router import ( _ "Gwen/docs/admin" + "Gwen/global" "Gwen/http/controller/admin" "Gwen/http/controller/admin/my" "Gwen/http/middleware" @@ -14,7 +15,9 @@ func Init(g *gin.Engine) { //swagger //g.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) - g.GET("/admin/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("admin"))) + if global.Config.App.ShowSwagger == 1 { + g.GET("/admin/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("admin"))) + } adg := g.Group("/api/admin") LoginBind(adg) diff --git a/http/router/api.go b/http/router/api.go index e25b457..9b2fe86 100644 --- a/http/router/api.go +++ b/http/router/api.go @@ -15,7 +15,9 @@ func ApiInit(g *gin.Engine) { //g.Use(middleware.Cors()) //swagger - g.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("api"))) + if global.Config.App.ShowSwagger == 1 { + g.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("api"))) + } frg := g.Group("/api")