http.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package http
  2. import (
  3. "go-common/app/job/main/upload/conf"
  4. "go-common/app/job/main/upload/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) {
  13. initService(c)
  14. // init router
  15. engineInner := bm.DefaultServer(c.BM.Inner)
  16. outerRouter(engineInner)
  17. if err := engineInner.Start(); err != nil {
  18. log.Error("bm.DefaultServer error(%v)", err)
  19. panic(err)
  20. }
  21. engineLocal := bm.DefaultServer(c.BM.Local)
  22. localRouter(engineLocal)
  23. if err := engineLocal.Start(); err != nil {
  24. log.Error("bm.DefaultServer error(%v)", err)
  25. panic(err)
  26. }
  27. }
  28. // initService init services.
  29. func initService(c *conf.Config) {
  30. svc = service.New(c)
  31. }
  32. // outerRouter init outer router api path.
  33. func outerRouter(e *bm.Engine) {
  34. //init api
  35. e.GET("/monitor/ping", ping)
  36. group := e.Group("/x/job/main/upload")
  37. {
  38. group.GET("")
  39. }
  40. }
  41. // ping check server ok.
  42. func ping(c *bm.Context) {
  43. svc.Ping(c)
  44. }
  45. // innerRouter init local router api path.
  46. func localRouter(e *bm.Engine) {
  47. group := e.Group("")
  48. {
  49. group.GET("")
  50. }
  51. }