http.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package http
  2. import (
  3. "net/http"
  4. "go-common/app/service/openplatform/ticket-item/conf"
  5. "go-common/app/service/openplatform/ticket-item/service"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. var (
  10. itemSvc *service.ItemService
  11. )
  12. // Init init item service.
  13. func Init(c *conf.Config, s *service.ItemService) {
  14. itemSvc = s
  15. //engineIn := bm.DefaultServer(c.BM.Inner)
  16. engineIn := bm.DefaultServer(nil)
  17. innerRouter(engineIn)
  18. // init inner server
  19. if err := engineIn.Start(); err != nil {
  20. log.Error("engineIn.Start error(%v)", err)
  21. panic(err)
  22. }
  23. /** unused
  24. engineLocal := bm.DefaultServer(c.BM.Local)
  25. localRouter(engineLocal)
  26. // init local router
  27. if err := engineLocal.Start(); err != nil {
  28. log.Error("engineLocal.Start error(%v)", err)
  29. panic(err)
  30. }**/
  31. }
  32. // innerRouter init inner router.
  33. func innerRouter(e *bm.Engine) {
  34. e.Ping(ping)
  35. // item
  36. group := e.Group("/openplatform/internal/ticket/item")
  37. {
  38. group.GET("/info", info)
  39. group.GET("/billinfo", billInfo)
  40. group.GET("/cards", cards)
  41. // group.GET("/guestinfo", guestInfo)
  42. // group.GET("/gueststatus", guestStatus)
  43. //group.GET("/getguests", getGuests)
  44. //group.GET("/getbulletins", getBulletins)
  45. group.GET("/guest/search", guestSearch)
  46. group.GET("/venue/search", venueSearch) // 场馆搜索
  47. group.GET("/version/search", versionSearch) // 项目版本搜索
  48. group.POST("/wishstatus", wish) // 想去项目
  49. group.POST("/favstatus", fav) // 收藏/取消收藏项目
  50. group.POST("/venueinfo", venueInfo)
  51. group.POST("/placeinfo", placeInfo)
  52. group.POST("/areainfo", areaInfo)
  53. group.POST("/seatinfo", seatInfo)
  54. group.POST("/seatStock", seatStock)
  55. group.POST("/removeSeatOrders", removeSeatOrders)
  56. }
  57. }
  58. // localRouter init local router.
  59. /**func localRouter(e *bm.Engine) {
  60. }**/
  61. // ping check server ok.
  62. func ping(c *bm.Context) {
  63. if err := itemSvc.Ping(c); err != nil {
  64. log.Error("ticket http service ping error(%v)", err)
  65. c.AbortWithStatus(http.StatusServiceUnavailable)
  66. }
  67. }