http.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package http
  2. import (
  3. "net/http"
  4. "go-common/app/service/openplatform/ticket-sales/conf"
  5. "go-common/app/service/openplatform/ticket-sales/service"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. var (
  10. svc *service.Service
  11. )
  12. // Init init ticket service.
  13. func Init(c *conf.Config, s *service.Service) {
  14. svc = s
  15. // init router
  16. engine := bm.DefaultServer(c.BM)
  17. initRouter(engine)
  18. outerRouter(engine)
  19. if err := engine.Start(); err != nil {
  20. log.Error("engine.Start error(%v)", err)
  21. panic(err)
  22. }
  23. }
  24. // initRouter init inner router.
  25. func initRouter(e *bm.Engine) {
  26. e.Ping(ping)
  27. // 等依赖方修改后,再删除
  28. group := e.Group("/x/internal/ticket/sales")
  29. {
  30. group.POST("/distrib/syncorder", syncOrder)
  31. group.GET("/distrib/getorder", getOrder)
  32. }
  33. //ticket
  34. group = e.Group("/openplatform/internal/ticket/sales")
  35. {
  36. group.POST("/distrib/syncorder", syncOrder)
  37. group.GET("/distrib/getorder", getOrder)
  38. group.POST("/promo/order/check", checkCreatePromoOrder)
  39. group.POST("/promo/order/create", createPromoOrder)
  40. group.GET("/promo/order/pay", payNotify)
  41. group.GET("/promo/order/cancel", cancelOrder)
  42. group.GET("/promo/order/check/issue", checkIssue)
  43. group.POST("/promo/order/finish/issue", finishIssue)
  44. group.GET("/promo/get", getPromo)
  45. group.POST("promo/create", createPromo)
  46. group.POST("promo/operate", operatePromo)
  47. group.POST("promo/edit", editPromo)
  48. group.POST("/settle/compare", settleCompare)
  49. group.POST("/settle/repush", settleRepush)
  50. }
  51. }
  52. // outerRouter init inner router.
  53. func outerRouter(e *bm.Engine) {
  54. }
  55. // ping check server ok.
  56. func ping(c *bm.Context) {
  57. if err := svc.Ping(c); err != nil {
  58. log.Error("ticket http service ping error(%v)", err)
  59. c.AbortWithStatus(http.StatusServiceUnavailable)
  60. }
  61. }