http.go 895 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package http
  2. import (
  3. "go-common/app/infra/canal/conf"
  4. "go-common/app/infra/canal/service"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. var (
  9. cs *service.Canal
  10. )
  11. // Init int http service
  12. func Init(c *conf.Config, cs *service.Canal) {
  13. initService(cs)
  14. // init router
  15. eg := bm.DefaultServer(c.BM)
  16. initRouter(eg)
  17. // init Outer serve
  18. if err := eg.Start(); err != nil {
  19. log.Error("bm.DefaultServer error(%v)", err)
  20. panic(err)
  21. }
  22. }
  23. func initService(canal *service.Canal) {
  24. cs = canal
  25. }
  26. // initRouter init outer router api path.
  27. func initRouter(e *bm.Engine) {
  28. // init api
  29. e.Ping(ping)
  30. group := e.Group("/x/internal/canal")
  31. {
  32. group.GET("/infoc/post", infocPost)
  33. group.GET("/infoc/current", infocCurrent)
  34. group.GET("/errors", errors)
  35. group.POST("/master/check", checkMaster)
  36. group.POST("/test/sync", syncPos)
  37. }
  38. }
  39. func ping(c *bm.Context) {
  40. }