router.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package router
  2. import (
  3. tingyun_gin "github.com/TingYunAPM/go/framework/gin"
  4. "github.com/gin-gonic/gin"
  5. "github.com/swaggo/gin-swagger"
  6. "github.com/swaggo/gin-swagger/swaggerFiles"
  7. "gopkg"
  8. "lzyd-message-api/controllers"
  9. _ "lzyd-message-api/docs" // docs is generated by Swag CLI, you have to import it.
  10. "lzyd-message-api/middleware"
  11. )
  12. func InitRouter() *tingyun_gin.WrapEngine {
  13. // Creates a gin router with default middleware:
  14. // logger and recovery (crash-free) middleware
  15. router := tingyun_gin.Default()
  16. router.Use(gin.Recovery())
  17. router.Use(gopkg.CORSMiddleware())
  18. // use ginSwagger middleware to
  19. router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  20. // 微信授权
  21. //wx := router.Group("/wx")
  22. //wx.GET("/h5/login", controllers.Login)
  23. api := router.Group("/api")
  24. api.Use(middleware.ValidSign(true))
  25. // api.Use(middleware.ValidHeaderParams(true))
  26. /// 房间管理
  27. api.POST("/chatroom/join", controllers.JoinChatroom)
  28. api.POST("/chatroom/leave", controllers.LeaveChatroom)
  29. api.POST("/chatroom/create", controllers.CreateChatroom)
  30. api.GET("/chatroom/list", controllers.GetChatroomList)
  31. api.GET("/chatroom/delete", controllers.DeleteChatroom)
  32. api.POST("/chatroom/joinCreate", controllers.JoinCreateChatroom)
  33. // 消息管理
  34. api.POST("/message/send", controllers.SendMessage)
  35. api.GET("/message/timeline", controllers.GetMessages)
  36. api.GET("/message/notice", controllers.GetNoticeType)
  37. api.POST("/message/notice/read", controllers.ReadNotice)
  38. api.GET("/message/interact", controllers.GetInteract)
  39. api.GET("/message/deleteInteract", controllers.DeleteInteract)
  40. // 直播间
  41. api.GET("/chatroom/detail", controllers.ChatroomDetail)
  42. return router
  43. }