我正在研究一个心跳故障检测器,在前端我正在使用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,
)

没有做我需要的 . 我能做什么?