http.go 929 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package http
  2. import (
  3. "go-common/app/infra/discovery/conf"
  4. "go-common/app/infra/discovery/service"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. var (
  9. svr *service.Service
  10. )
  11. // Init init http
  12. func Init(c *conf.Config, s *service.Service) {
  13. svr = s
  14. engineInner := bm.DefaultServer(c.BM.Inner)
  15. innerRouter(engineInner)
  16. if err := engineInner.Start(); err != nil {
  17. log.Error("bm.DefaultServer error(%v)", err)
  18. panic(err)
  19. }
  20. }
  21. // innerRouter init local router api path.
  22. func innerRouter(e *bm.Engine) {
  23. group := e.Group("/discovery")
  24. {
  25. group.POST("/register", register)
  26. group.POST("/renew", renew)
  27. group.POST("/cancel", cancel)
  28. group.GET("/fetch/all", fetchAll)
  29. group.GET("/fetch", fetch)
  30. group.GET("/fetchs", fetchs)
  31. group.GET("/poll", poll)
  32. group.GET("/polls", polls)
  33. //manager
  34. group.POST("/set", set)
  35. group.GET("/polling", polling)
  36. group.GET("/nodes", nodes)
  37. }
  38. }