routes.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Code generated by goctl. DO NOT EDIT.
  2. // goctl 1.7.3
  3. package handler
  4. import (
  5. "net/http"
  6. room "microGame/app/usercenter/cmd/api/internal/handler/room"
  7. user "microGame/app/usercenter/cmd/api/internal/handler/user"
  8. "microGame/app/usercenter/cmd/api/internal/svc"
  9. "github.com/zeromicro/go-zero/rest"
  10. )
  11. func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
  12. server.AddRoutes(
  13. []rest.Route{
  14. {
  15. // bet room
  16. Method: http.MethodPost,
  17. Path: "/bet",
  18. Handler: room.BetHandler(serverCtx),
  19. },
  20. {
  21. // chat room
  22. Method: http.MethodPost,
  23. Path: "/chat",
  24. Handler: room.ChatHandler(serverCtx),
  25. },
  26. {
  27. // create room
  28. Method: http.MethodPost,
  29. Path: "/create",
  30. Handler: room.CreateRoomHandler(serverCtx),
  31. },
  32. {
  33. // join room
  34. Method: http.MethodPost,
  35. Path: "/join",
  36. Handler: room.JoinRoomHandler(serverCtx),
  37. },
  38. {
  39. // leave room
  40. Method: http.MethodPost,
  41. Path: "/leave",
  42. Handler: room.LeaveRoomHandler(serverCtx),
  43. },
  44. {
  45. // get room list
  46. Method: http.MethodPost,
  47. Path: "/list",
  48. Handler: room.RoomListHandler(serverCtx),
  49. },
  50. {
  51. // sitDown room
  52. Method: http.MethodPost,
  53. Path: "/sitdown",
  54. Handler: room.SitDownHandler(serverCtx),
  55. },
  56. {
  57. // standUp
  58. Method: http.MethodPost,
  59. Path: "/standup",
  60. Handler: room.StandUpHandler(serverCtx),
  61. },
  62. },
  63. rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
  64. rest.WithPrefix("/api/room"),
  65. )
  66. server.AddRoutes(
  67. rest.WithMiddlewares(
  68. []rest.Middleware{serverCtx.UserAgentMiddleware},
  69. []rest.Route{
  70. {
  71. // login
  72. Method: http.MethodPost,
  73. Path: "/login",
  74. Handler: user.LoginHandler(serverCtx),
  75. },
  76. {
  77. // register
  78. Method: http.MethodPost,
  79. Path: "/register",
  80. Handler: user.RegisterHandler(serverCtx),
  81. },
  82. }...,
  83. ),
  84. rest.WithPrefix("/api/user"),
  85. )
  86. server.AddRoutes(
  87. []rest.Route{
  88. {
  89. // get user info
  90. Method: http.MethodPost,
  91. Path: "/detail",
  92. Handler: user.DetailHandler(serverCtx),
  93. },
  94. {
  95. // get user info
  96. Method: http.MethodPost,
  97. Path: "/logout",
  98. Handler: user.LogoutHandler(serverCtx),
  99. },
  100. },
  101. rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
  102. rest.WithPrefix("/api/user"),
  103. )
  104. server.AddRoutes(
  105. []rest.Route{
  106. {
  107. // ws
  108. Method: http.MethodGet,
  109. Path: "/ws",
  110. Handler: user.WsHandler(serverCtx),
  111. },
  112. },
  113. rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
  114. rest.WithPrefix("/api"),
  115. )
  116. }