http.go 656 B

123456789101112131415161718192021222324252627282930313233343536
  1. package http
  2. import (
  3. "go-common/app/job/main/point/conf"
  4. "go-common/app/job/main/point/service"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. var (
  9. svc *service.Service
  10. )
  11. // Init init
  12. func Init(c *conf.Config, s *service.Service) {
  13. // service init
  14. svc = s
  15. // init router
  16. engineInner := bm.DefaultServer(c.BM)
  17. innerRouter(engineInner)
  18. if err := engineInner.Start(); err != nil {
  19. log.Error("engineInner.Start error(%v)", err)
  20. panic(err)
  21. }
  22. }
  23. // outerRouter init outer router api path.
  24. func innerRouter(e *bm.Engine) {
  25. //init api
  26. e.Ping(ping)
  27. }
  28. // ping check server ok.
  29. func ping(c *bm.Context) {
  30. svc.Ping(c)
  31. }