package ws

import (
	"be.ems/src/framework/logger"
	"be.ems/src/framework/middleware"
	"be.ems/src/framework/middleware/collectlogs"
	"be.ems/src/modules/ws/controller"

	"github.com/gin-gonic/gin"
)

// 模块路由注册
func Setup(router *gin.Engine) {
	logger.Infof("开始加载 ====> ws 模块路由")

	// WebSocket 协议
	ws := controller.NewWSController
	wsGroup := router.Group("/ws")
	{
		wsGroup.GET("",
			middleware.AuthorizeUser(nil),
			ws.WS,
		)
		wsGroup.GET("/test",
			middleware.AuthorizeUser(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.ws", collectlogs.BUSINESS_TYPE_OTHER)),
			ws.Test,
		)
		wsGroup.GET("/ssh",
			middleware.AuthorizeUser(nil),
			ws.SSH,
		)
		wsGroup.GET("/telnet",
			middleware.AuthorizeUser(nil),
			ws.Telnet,
		)
		wsGroup.GET("/redis",
			middleware.AuthorizeUser(nil),
			ws.Redis,
		)
		wsGroup.GET("/view",
			middleware.AuthorizeUser(nil),
			ws.ShellView,
		)
	}
}
