http.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package http
  2. import (
  3. "go-common/app/interface/main/app-view/conf"
  4. "go-common/app/interface/main/app-view/service/report"
  5. "go-common/app/interface/main/app-view/service/view"
  6. "go-common/library/log"
  7. "go-common/library/log/anticheat"
  8. bm "go-common/library/net/http/blademaster"
  9. "go-common/library/net/http/blademaster/middleware/auth"
  10. "go-common/library/net/http/blademaster/middleware/proxy"
  11. "go-common/library/net/http/blademaster/middleware/verify"
  12. "go-common/library/queue/databus"
  13. )
  14. var (
  15. viewSvr *view.Service
  16. reportSvr *report.Service
  17. authSvr *auth.Auth
  18. verifySvc *verify.Verify
  19. // databus
  20. userActPub *databus.Databus
  21. dislikePub *databus.Databus
  22. collector *anticheat.AntiCheat
  23. )
  24. type userAct struct {
  25. Client string `json:"client"`
  26. Buvid string `json:"buvid"`
  27. Mid int64 `json:"mid"`
  28. Time int64 `json:"time"`
  29. From string `json:"from"`
  30. Build string `json:"build"`
  31. ItemID string `json:"item_id"`
  32. ItemType string `json:"item_type"`
  33. Action string `json:"action"`
  34. ActionID string `json:"action_id"`
  35. Extra string `json:"extra"`
  36. }
  37. type cmDislike struct {
  38. ID int64 `json:"id"`
  39. Buvid string `json:"buvid"`
  40. Goto string `json:"goto"`
  41. Mid int64 `json:"mid"`
  42. ReasonID int64 `json:"reason_id"`
  43. CMReasonID int64 `json:"cm_reason_id"`
  44. UpperID int64 `json:"upper_id"`
  45. Rid int64 `json:"rid"`
  46. TagID int64 `json:"tag_id"`
  47. ADCB string `json:"ad_cb"`
  48. }
  49. // Init init http
  50. func Init(c *conf.Config) {
  51. initService(c)
  52. collector = anticheat.New(c.InfocCoin)
  53. // init external router
  54. engineOut := bm.DefaultServer(c.BM.Outer)
  55. outerRouter(engineOut)
  56. // init outer server
  57. if err := engineOut.Start(); err != nil {
  58. log.Error("engineOut.Start() error(%v)", err)
  59. panic(err)
  60. }
  61. }
  62. func initService(c *conf.Config) {
  63. verifySvc = verify.New(nil)
  64. authSvr = auth.New(nil)
  65. viewSvr = view.New(c)
  66. reportSvr = report.New(c)
  67. // databus
  68. userActPub = databus.New(c.UseractPub)
  69. dislikePub = databus.New(c.DislikePub)
  70. }
  71. func outerRouter(e *bm.Engine) {
  72. e.Ping(ping)
  73. // view
  74. proxyHandler := proxy.NewZoneProxy("sh004", "http://sh001-app.bilibili.com")
  75. view := e.Group("/x/v2/view")
  76. view.GET("", verifySvc.Verify, authSvr.GuestMobile, viewIndex)
  77. view.GET("/page", verifySvc.Verify, authSvr.GuestMobile, viewPage)
  78. view.GET("/video/shot", verifySvc.Verify, videoShot)
  79. view.POST("/share/add", verifySvc.Verify, authSvr.GuestMobile, addShare)
  80. view.POST("/coin/add", proxyHandler, authSvr.UserMobile, addCoin)
  81. view.POST("/fav/add", authSvr.UserMobile, addFav)
  82. view.POST("/ad/dislike", authSvr.GuestMobile, adDislike)
  83. view.GET("/report", verifySvc.Verify, copyWriter)
  84. view.POST("/report/add", authSvr.UserMobile, addReport)
  85. view.POST("/report/upload", verifySvc.Verify, upload)
  86. view.POST("/like", proxyHandler, authSvr.UserMobile, like)
  87. view.POST("/dislike", authSvr.UserMobile, dislike)
  88. view.POST("/vip/playurl", authSvr.UserMobile, vipPlayURL)
  89. view.GET("/follow", authSvr.GuestMobile, follow)
  90. view.GET("/upper/recmd", authSvr.GuestMobile, upperRecmd)
  91. view.POST("/like/triple", authSvr.UserMobile, likeTriple)
  92. // bnj2019
  93. view.GET("/bnj2019", verifySvc.Verify, authSvr.GuestMobile, bnj2019)
  94. view.GET("/bnj2019/list", verifySvc.Verify, authSvr.GuestMobile, bnjList)
  95. view.GET("/bnj2019/item", verifySvc.Verify, authSvr.GuestMobile, bnjItem)
  96. }