LingxinMeng 10 ay önce
ebeveyn
işleme
fa53477cb6
2 değiştirilmiş dosya ile 22 ekleme ve 14 silme
  1. 20 13
      src/main/main.go
  2. 2 1
      src/package/handler/old_interface_adapter.go

+ 20 - 13
src/main/main.go

@@ -69,18 +69,25 @@ func main() {
 	go service.RunWaitingCluster()
 
 	// 启动 web 服务器
-	router := gin.Default()
-	//router.Use(commonHandler.ValidateHeaders()) // todo 暂时不需要校验
-	router.Use(middleware.Cors()) // 解决cors
-	api1 := router.Group(infra.ApplicationYaml.Web.RoutePrefix)
-	api1.POST("/start-project", handler.StartProject)
-	api2 := router.Group("/simulation/resource/scheduler/task")
-	api2.GET("/confirm", handler.Confirm)
-	api2.GET("/tick", handler.Tick)
-	api2.GET("/state", handler.State)
-	err := router.Run(":" + infra.ApplicationYaml.Web.Port)
-	if err != nil {
-		infra.GlobalLogger.Error("程序崩溃,监听端口 " + util.ToString(infra.ApplicationYaml.Web.Port) + " 失败。")
-		os.Exit(-1)
+	{
+		router := gin.Default()
+		router.Use(middleware.Cors()) // 解决cors
+		{
+			api1 := router.Group(infra.ApplicationYaml.Web.RoutePrefix)
+			api1.POST("/start-project", handler.StartProject)
+		}
+		{
+			api2 := router.Group("/simulation/resource/scheduler/task")
+			api2.GET("/confirm", handler.Confirm)
+			api2.GET("/tick", handler.Tick)
+			api2.GET("/state", handler.State)
+		}
+
+		err := router.Run(":" + infra.ApplicationYaml.Web.Port)
+		if err != nil {
+			infra.GlobalLogger.Error("程序崩溃,监听端口 " + util.ToString(infra.ApplicationYaml.Web.Port) + " 失败。")
+			os.Exit(-1)
+		}
 	}
+
 }

+ 2 - 1
src/package/handler/old_interface_adapter.go

@@ -11,11 +11,12 @@ import (
 	"net/http"
 )
 
-// 返回 true
+// Confirm 返回 true(用来确认任务是否执行的,直接返回 true 即可)
 func Confirm(c *gin.Context) {
 	c.String(http.StatusOK, "true")
 }
 
+// Tick 接收心跳,此处没有其他处理
 func Tick(c *gin.Context) {
 	c.String(http.StatusOK, "true")
 }