提交 8aa0b2ed authored 作者: mooncake9527's avatar mooncake9527

update

上级 290e6fd6
...@@ -58,6 +58,7 @@ func (x *Application) Run() { ...@@ -58,6 +58,7 @@ func (x *Application) Run() {
services := CreateServices(x.h()) services := CreateServices(x.h())
closes := Close(services) closes := Close(services)
x.app = app.New(services, closes) x.app = app.New(services, closes)
eventbus.Eb.Publish(context.TODO(), eventbus.TopicPrintSwagger)
x.app.Run() x.app.Run()
} }
......
package xgin package xgin
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"time" "time"
...@@ -18,6 +19,7 @@ import ( ...@@ -18,6 +19,7 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/gin/prof" "gitlab.wanzhuangkj.com/tush/xpkg/gin/prof"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/validator" "gitlab.wanzhuangkj.com/tush/xpkg/gin/validator"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
...@@ -96,13 +98,13 @@ func New() *gin.Engine { ...@@ -96,13 +98,13 @@ func New() *gin.Engine {
if config.IsNotProd() { if config.IsNotProd() {
r.GET(consts.RootRoute+"/config", gin.WrapF(errcode.ShowConfig([]byte(config.Show())))) r.GET(consts.RootRoute+"/config", gin.WrapF(errcode.ShowConfig([]byte(config.Show()))))
r.GET(consts.RootRoute+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) r.GET(consts.RootRoute+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
defer func() { eventbus.Eb.Subscribe(eventbus.TopicPrintSwagger, func(ctx context.Context) {
fmt.Println(text.Blue(fmt.Sprintf("swagger: http://localhost:%d"+consts.RootRoute+"/swagger/index.html", httpCfg.Port))) fmt.Println(text.Blue(fmt.Sprintf("swagger: http://localhost:%d"+consts.RootRoute+"/swagger/index.html", httpCfg.Port)))
ip := ips.GetLocalHost() ip := ips.GetLocalHost()
if ip != "" { if ip != "" {
fmt.Println(text.Blue(fmt.Sprintf("swagger: https://%s:%d"+consts.RootRoute+"/swagger/index.html", ip, httpCfg.Port))) fmt.Println(text.Blue(fmt.Sprintf("swagger: https://%s:%d"+consts.RootRoute+"/swagger/index.html", ip, httpCfg.Port)))
} }
}() })
} }
r.GET("/health", handlerfunc.CheckHealth) r.GET("/health", handlerfunc.CheckHealth)
......
...@@ -9,5 +9,6 @@ const ( ...@@ -9,5 +9,6 @@ const (
TopicCacheInitFinish string = "event:application:cache:init:finish" // cache初始化完成 TopicCacheInitFinish string = "event:application:cache:init:finish" // cache初始化完成
TopicCronInitFinish string = "event:application:cron:init:finish" // 定时任务初始化完成 TopicCronInitFinish string = "event:application:cron:init:finish" // 定时任务初始化完成
TopicCoreInitFinish string = "event:application:core:init:finish" // 核心服务初始化完成 TopicCoreInitFinish string = "event:application:core:init:finish" // 核心服务初始化完成
TopicPrintSwagger string = "event:swagger:print" // 打印swagger doc info
TopicApplicationClose string = "event:application:close" // 应用关闭 TopicApplicationClose string = "event:application:close" // 应用关闭
) )
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论