package router import ( tingyun_gin "github.com/TingYunAPM/go/framework/gin" "github.com/gin-gonic/gin" "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" "gopkg" "lzyd-message-api/controllers" _ "lzyd-message-api/docs" // docs is generated by Swag CLI, you have to import it. "lzyd-message-api/middleware" ) func InitRouter() *tingyun_gin.WrapEngine { // Creates a gin router with default middleware: // logger and recovery (crash-free) middleware router := tingyun_gin.Default() router.Use(gin.Recovery()) router.Use(gopkg.CORSMiddleware()) // use ginSwagger middleware to router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) // 微信授权 //wx := router.Group("/wx") //wx.GET("/h5/login", controllers.Login) api := router.Group("/api") api.Use(middleware.ValidSign(true)) // api.Use(middleware.ValidHeaderParams(true)) /// 房间管理 api.POST("/chatroom/join", controllers.JoinChatroom) api.POST("/chatroom/leave", controllers.LeaveChatroom) api.POST("/chatroom/create", controllers.CreateChatroom) api.GET("/chatroom/list", controllers.GetChatroomList) api.GET("/chatroom/delete", controllers.DeleteChatroom) api.POST("/chatroom/joinCreate", controllers.JoinCreateChatroom) // 消息管理 api.POST("/message/send", controllers.SendMessage) api.GET("/message/timeline", controllers.GetMessages) api.GET("/message/notice", controllers.GetNoticeType) api.POST("/message/notice/read", controllers.ReadNotice) api.GET("/message/interact", controllers.GetInteract) api.GET("/message/deleteInteract", controllers.DeleteInteract) // 直播间 api.GET("/chatroom/detail", controllers.ChatroomDetail) return router }