提交 4d9148df authored 作者: mooncake9527's avatar mooncake9527

context path

上级 8f949fb3
...@@ -224,6 +224,7 @@ type Email struct { ...@@ -224,6 +224,7 @@ type Email struct {
type App struct { type App struct {
CacheType string `yaml:"cacheType" json:"cacheType"` CacheType string `yaml:"cacheType" json:"cacheType"`
ContextPath string `yaml:"contextPath" json:"contextPath"`
Middleware Middleware `yaml:"middleware" json:"middleware"` Middleware Middleware `yaml:"middleware" json:"middleware"`
Env string `yaml:"env" json:"env"` Env string `yaml:"env" json:"env"`
......
...@@ -17,7 +17,9 @@ func Init() { ...@@ -17,7 +17,9 @@ func Init() {
func initLocalCron() { func initLocalCron() {
var cron config.Cron var cron config.Cron
contextPath := ""
config.Read(func(c *config.Config) { config.Read(func(c *config.Config) {
contextPath = c.App.ContextPath
_ = copier.Copy(&cron, c.Cron) _ = copier.Copy(&cron, c.Cron)
}) })
if !cron.Enable { if !cron.Enable {
...@@ -34,6 +36,6 @@ func initLocalCron() { ...@@ -34,6 +36,6 @@ func initLocalCron() {
initCron() initCron()
g := global.G.Engine g := global.G.Engine
if g != nil { if g != nil {
engine.RegisterRouters(g, "/internal", CronRouterApis) engine.RegisterRouters(g, contextPath+"/internal", CronRouterApis)
} }
} }
...@@ -15,7 +15,7 @@ func init() { ...@@ -15,7 +15,7 @@ func init() {
func cronJobRouter(group *gin.RouterGroup) { func cronJobRouter(group *gin.RouterGroup) {
c := controller.CronJobController c := controller.CronJobController
g := group.Group("/cronJob") g := group.Group("/cron")
g.POST("/startByCode", c.StartByCode) g.POST("/startByCode", c.StartByCode)
g.POST("/stopByCode", c.StopByCode) g.POST("/stopByCode", c.StopByCode)
g.POST("/callByCode", c.CallOnceByCode) g.POST("/callByCode", c.CallOnceByCode)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论