http.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package http
  2. import (
  3. "go-common/app/interface/main/videoup/conf"
  4. "go-common/app/interface/main/videoup/service"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/http/blademaster/middleware/antispam"
  8. "go-common/library/net/http/blademaster/middleware/auth"
  9. "go-common/library/net/http/blademaster/middleware/verify"
  10. )
  11. var (
  12. vdpSvc *service.Service
  13. antiSvc *antispam.Antispam
  14. verifySvc *verify.Verify
  15. authSvc *auth.Auth
  16. )
  17. // Init fn
  18. func Init(c *conf.Config, s *service.Service) {
  19. initService(c)
  20. engineOuter := bm.DefaultServer(c.BM)
  21. outerRouter(engineOuter)
  22. if err := engineOuter.Start(); err != nil {
  23. log.Error("engineOuter.Start() error(%v) | config(%v)", err, c)
  24. panic(err)
  25. }
  26. }
  27. // initService init service
  28. func initService(c *conf.Config) {
  29. verifySvc = verify.New(nil)
  30. authSvc = auth.New(nil)
  31. vdpSvc = service.New(c)
  32. antiSvc = antispam.New(c.UpCoverAnti)
  33. }
  34. // outerRouter ForLogic port:6321
  35. func outerRouter(e *bm.Engine) {
  36. e.GET("/monitor/ping", ping)
  37. g := e.Group("/x/vu")
  38. {
  39. client := g.Group("/client")
  40. {
  41. client.POST("/add", authSvc.UserMobile, clientAdd)
  42. client.POST("/edit", authSvc.UserMobile, clientEdit)
  43. client.POST("/cover/up", authSvc.UserMobile, antiSvc.Handler(), clientUpCover)
  44. }
  45. web := g.Group("/web")
  46. {
  47. web.POST("/add", authSvc.UserWeb, webAdd)
  48. web.POST("/edit", authSvc.UserWeb, webEdit)
  49. web.POST("/cover/up", authSvc.UserWeb, antiSvc.Handler(), webUpCover)
  50. web.POST("/filter", authSvc.UserWeb, webFilter)
  51. web.POST("/staff-title/filter", authSvc.UserWeb, webStaffTitleFilter)
  52. web.POST("/cm/add", authSvc.UserWeb, webCmAdd)
  53. web.POST("/v2/add", authSvc.UserWeb, webV2Add)
  54. }
  55. app := g.Group("/app")
  56. {
  57. app.POST("/edit", authSvc.UserMobile, appEdit)
  58. //new feature
  59. app.POST("/add", authSvc.UserMobile, appAdd)
  60. app.POST("/edit/full", authSvc.UserMobile, appEditFull)
  61. app.POST("/cover/up", authSvc.UserMobile, antiSvc.Handler(), appUpCover)
  62. }
  63. creator := g.Group("/creator")
  64. {
  65. creator.POST("/add", authSvc.UserMobile, creatorAdd)
  66. creator.POST("/edit", authSvc.UserMobile, creatorEdit)
  67. creator.POST("/cover/up", authSvc.UserMobile, antiSvc.Handler(), creatorUpCover)
  68. }
  69. }
  70. }
  71. func getBuildInfo(c *bm.Context) (build, buvid string) {
  72. buvid = c.Request.Header.Get("Buvid")
  73. if buvid == "" {
  74. buvidCookie, _ := c.Request.Cookie("buvid3")
  75. if buvidCookie != nil {
  76. buvid = buvidCookie.Value
  77. }
  78. }
  79. build = c.Request.Form.Get("build")
  80. return
  81. }