http.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package http
  2. import (
  3. "go-common/app/interface/live/app-room/api/http/v1"
  4. "go-common/app/interface/live/app-room/conf"
  5. "go-common/app/interface/live/app-room/service"
  6. resSrv "go-common/app/interface/live/app-room/service/v1"
  7. v1Svc "go-common/app/interface/live/app-room/service/v1"
  8. dm "go-common/app/interface/live/app-room/service/v1/dm"
  9. "go-common/library/log"
  10. bm "go-common/library/net/http/blademaster"
  11. "go-common/library/net/http/blademaster/middleware/auth"
  12. )
  13. var (
  14. srv *service.Service
  15. midAuth *auth.Auth
  16. dmservice *dm.DMService
  17. )
  18. // Init init
  19. func Init(c *conf.Config, svc *service.Service) {
  20. srv = svc
  21. resSrv.Init(c)
  22. initService(c)
  23. engine := bm.DefaultServer(c.BM)
  24. route(engine)
  25. if err := engine.Start(); err != nil {
  26. log.Error("bm Start error(%v)", err)
  27. panic(err)
  28. }
  29. }
  30. func initService(c *conf.Config) {
  31. dmservice = dm.NewDMService(c)
  32. midAuth = auth.New(c.Auth)
  33. }
  34. func route(e *bm.Engine) {
  35. e.Ping(ping)
  36. e.Register(register)
  37. g := e.Group("/xlive/app-room")
  38. {
  39. g.GET("/v1/banner/getBanner", resSrv.GetBanner)
  40. }
  41. midMap := map[string]bm.HandlerFunc{
  42. "guest": midAuth.Guest,
  43. "auth": midAuth.User,
  44. }
  45. v1.RegisterV1GiftService(e, v1Svc.NewGiftService(conf.Conf), midMap)
  46. v1.RegisterV1RoomNoticeService(e, resSrv.NewRoomNoticeService(conf.Conf), midMap)
  47. g.POST("/v1/dM/sendmsg", midAuth.User, sendMsgSendMsg)
  48. g.GET("/v1/dM/gethistory", getHistory)
  49. }
  50. func ping(c *bm.Context) {
  51. }
  52. func register(c *bm.Context) {
  53. c.JSON(map[string]interface{}{}, nil)
  54. }