http.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package http
  2. import (
  3. "io"
  4. "go-common/app/service/main/location/conf"
  5. "go-common/app/service/main/location/service"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/net/http/blademaster/middleware/verify"
  9. )
  10. var (
  11. svr *service.Service
  12. vfySvc *verify.Verify
  13. )
  14. // Init init http.
  15. func Init(c *conf.Config, s *service.Service, rpcCloser io.Closer) {
  16. svr = s
  17. vfySvc = verify.New(c.Verify)
  18. // init external router
  19. engineInner := bm.DefaultServer(c.BM.Inner)
  20. innerRouter(engineInner)
  21. // init internal server
  22. if err := engineInner.Start(); err != nil {
  23. log.Error("engineInner.Start() error(%v) | config(%v)", err, c)
  24. panic(err)
  25. }
  26. }
  27. // innerRouter init inner router.
  28. func innerRouter(e *bm.Engine) {
  29. e.Ping(ping)
  30. e.Register(register)
  31. loc := e.Group("/x/location")
  32. // old api will delete soon
  33. loc.GET("/check", vfySvc.Verify, tmpInfo)
  34. loc.GET("/zone", vfySvc.Verify, tmpInfos)
  35. // ip info
  36. loc.GET("/info", vfySvc.Verify, info)
  37. loc.GET("/infos", vfySvc.Verify, infos)
  38. loc.GET("/info/complete", vfySvc.Verify, infoComplete)
  39. loc.GET("/infos/complete", vfySvc.Verify, infosComplete)
  40. loc.GET("/anonym", vfySvc.Verify, anonym)
  41. // area limit api
  42. zl := loc.Group("/zlimit")
  43. zl.GET("/pgc/in", vfySvc.Verify, pgcZone)
  44. zl.GET("/archive", vfySvc.Verify, auth)
  45. zl.GET("/archive2", vfySvc.Verify, archive2)
  46. zl.GET("/group", vfySvc.Verify, authGID)
  47. zl.GET("/groups", vfySvc.Verify, authGIDs)
  48. mng := loc.Group("/manager")
  49. mng.GET("/flushCache", vfySvc.Verify, flushCache)
  50. }