0

我正在开发一个心跳故障检测器,在前端我使用 Iris,前端正在检查后端是否处于活动状态。

前端是一个 Iris mvc 应用程序,通过以下方式完成:

app := iris.New()

app.StaticWeb("/", "./public")

// Configure the websocket server
ws := websocket.New(websocket.Config{})

jobAppsRouter := app.Party("/jobApplications")

jobAppsRouter.Any("/iris-ws.js", websocket.ClientHandler())

// Create the MVC object
jobApplicationsApp := mvc.New(jobAppsRouter)

然后我创建我的连接并执行以下操作

/ Create the service that interacts with the repo
jobAppService := services.NewJobApplicationService(conn)

// Dependencies
jobApplicationsApp.Register(
    jobAppService,
    ws.Upgrade,
)
// Controllers registration
jobApplicationsApp.Handle(new(controllers.JobAppController))
// Start the web server at http://localhost:8080
app.Run(iris.Addr(portStr))

这可以正常工作并正确启动应用程序。问题是稍后,我创建了一个到同一个后端的新连接,我想用它注册一个新服务。只需再次执行此操作 jobAppService := services.NewJobApplicationService(conn)

// Dependencies
jobApplicationsApp.Register(
    jobAppService,
    ws.Upgrade,
)

不做我需要的。我能做什么?

4

0 回答 0