http.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package http
  2. import (
  3. "go-common/app/interface/main/ugcpay/conf"
  4. "go-common/app/interface/main/ugcpay/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. )
  10. var (
  11. srv *service.Service
  12. authM *auth.Auth
  13. antispamM *antispam.Antispam
  14. )
  15. // Init init
  16. func Init(c *conf.Config, s *service.Service) {
  17. srv = s
  18. authM = auth.New(c.Auth)
  19. antispamM = antispam.New(c.Antispam)
  20. engine := bm.DefaultServer(c.BM)
  21. route(engine)
  22. if err := engine.Start(); err != nil {
  23. log.Error("bm Start error(%+v)", err)
  24. panic(err)
  25. }
  26. }
  27. func route(e *bm.Engine) {
  28. e.Ping(ping)
  29. web := e.Group("/x/ugcpay", authM.UserWeb)
  30. {
  31. web.GET("/trade", tradeQuery)
  32. web.POST("/trade/confirm", antispamM.Handler(), tradeConfirm)
  33. web.POST("/trade/create", antispamM.Handler(), tradeCreate)
  34. web.POST("/trade/cancel", tradeCancel)
  35. web.GET("/income/asset/overview", antispamM.Handler(), incomeAssetOverview)
  36. web.GET("/income/asset/monthly", antispamM.Handler(), incomeAssetMonthly)
  37. }
  38. app := e.Group("/x/ugcpay/v1", authM.UserMobile)
  39. {
  40. app.GET("/trade", tradeQuery)
  41. app.POST("/trade/confirm", antispamM.Handler(), tradeConfirm)
  42. app.POST("/trade/create", antispamM.Handler(), tradeCreate)
  43. app.POST("/trade/cancel", tradeCancel)
  44. app.GET("/income/asset/overview", antispamM.Handler(), incomeAssetOverview)
  45. app.GET("/income/asset/monthly", antispamM.Handler(), incomeAssetMonthly)
  46. }
  47. }
  48. func ping(c *bm.Context) {
  49. }