http.go 711 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package http
  2. import (
  3. "go-common/app/job/main/figure-timer/conf"
  4. "go-common/app/job/main/figure-timer/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 a http server
  12. func Init(s *service.Service) {
  13. svc = s
  14. e := bm.DefaultServer(conf.Conf.BM)
  15. innerRouter(e)
  16. if err := e.Start(); err != nil {
  17. log.Error("%+v", err)
  18. panic(err)
  19. }
  20. }
  21. // innerRouter init inner router.
  22. func innerRouter(e *bm.Engine) {
  23. e.Ping(ping)
  24. }
  25. // ping check server ok.
  26. func ping(c *bm.Context) {
  27. // if err := svc.Ping(c); err != nil {
  28. // log.Error("figure-timer-job ping err (%+v)", err)
  29. // c.AbortWithStatus(http.StatusServiceUnavailable)
  30. // }
  31. }