http.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package http
  2. import (
  3. newbieService "go-common/app/interface/main/growup/service/newbie"
  4. "net/http"
  5. "go-common/app/interface/main/growup/conf"
  6. "go-common/app/interface/main/growup/service"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. "go-common/library/net/http/blademaster/middleware/auth"
  10. )
  11. var (
  12. svc *service.Service
  13. authSvr *auth.Auth
  14. newbieSvr *newbieService.Service
  15. )
  16. // Init http server
  17. func Init(c *conf.Config) {
  18. initService(c)
  19. engine := bm.DefaultServer(c.BM)
  20. setupInnerEngine(engine)
  21. if err := engine.Start(); err != nil {
  22. log.Error("engine.Start error(%v)", err)
  23. panic(err)
  24. }
  25. }
  26. func initService(c *conf.Config) {
  27. svc = service.New(c)
  28. authSvr = auth.New(nil)
  29. newbieSvr = newbieService.New(c)
  30. }
  31. func setupInnerEngine(e *bm.Engine) {
  32. e.Ping(ping)
  33. allowance := e.Group("/allowance/api/x/internal/growup")
  34. allowanceUp := allowance.Group("/up")
  35. {
  36. // allowanceUp.GET("/status", getUpStatus)
  37. allowanceUp.POST("/add", join)
  38. allowanceUp.POST("/quit", quit)
  39. allowanceUp.GET("/withdraw", getWithdraw)
  40. allowanceUp.POST("/withdraw/success", withdrawSuccess)
  41. }
  42. studio := e.Group("/studio/growup/web", authSvr.User)
  43. studioUp := studio.Group("/up")
  44. {
  45. studioUp.GET("/income/stat", upIncomeStat)
  46. studioUp.GET("/summary", upSummary)
  47. studioUp.GET("/archive/summary", archiveSummary)
  48. studioUp.GET("/charge", upCharge)
  49. studioUp.GET("/archive/income", archiveIncome)
  50. studioUp.GET("/archive/detail", archiveDetail)
  51. studioUp.GET("/archive/breach", archiveBreach)
  52. studioUp.GET("/withdraw/detail", withdrawDetail)
  53. studioUp.POST("/quit", quit1)
  54. studioUp.GET("/status", getUpStatus)
  55. studioUp.POST("/av/join", joinAv)
  56. studioUp.POST("/bgm/join", joinBgm)
  57. studioUp.POST("/column/join", joinColumn)
  58. studioUp.GET("/bill", upBill)
  59. studioUp.GET("/year", upYear)
  60. // 新手信
  61. studioUp.GET("/newbie/letter", upNewbieLetter)
  62. exchange := studioUp.Group("/exchange")
  63. {
  64. exchange.GET("/state", goodsState)
  65. exchange.GET("/show", goodsShow)
  66. exchange.GET("/record", goodsRecord)
  67. exchange.POST("/buy", goodsBuy)
  68. }
  69. }
  70. studioActivity := studio.Group("/activity")
  71. {
  72. studioActivity.GET("/show", showActivity)
  73. studioActivity.POST("/sign_up", signUpActivity)
  74. }
  75. specialAward := e.Group("/studio/growup/web/special/award", authSvr.Guest)
  76. {
  77. specialAward.GET("/info", sepcialAwardInfo)
  78. specialAward.GET("/detail", specialAwardDetail)
  79. specialAward.GET("/list", listSpecialAward)
  80. specialAward.GET("/winner", specialAwardWinners)
  81. }
  82. specialAwardUser := e.Group("/studio/growup/web/special/award", authSvr.User)
  83. {
  84. specialAwardUser.GET("/record", specialAwardRecord)
  85. specialAwardUser.GET("/record/poster", specialAwardPoster)
  86. specialAwardUser.GET("/up/status", specialAwardUpStatus)
  87. specialAwardUser.POST("/join", joinSpecialAward)
  88. }
  89. studio.GET("/notice/latest", latestNotice)
  90. studio.GET("/notices", notices)
  91. studio.GET("/banner", banner)
  92. }
  93. func ping(c *bm.Context) {
  94. var err error
  95. if err = svc.Ping(c); err != nil {
  96. log.Error("service ping error(%v)", err)
  97. c.AbortWithStatus(http.StatusServiceUnavailable)
  98. }
  99. }