http.go 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package http
  2. import (
  3. "go-common/app/job/main/passport-auth/conf"
  4. "go-common/app/job/main/passport-auth/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)
  16. outerRouter(engineInner)
  17. if err := engineInner.Start(); err != nil {
  18. log.Error("bm.DefaultServer error(%v)", err)
  19. panic(err)
  20. }
  21. }
  22. // initService init services.
  23. func initService(c *conf.Config) {
  24. svc = service.New(c)
  25. }
  26. // outerRouter init outer router api path.
  27. func outerRouter(e *bm.Engine) {
  28. //init api
  29. e.Ping(ping)
  30. }
  31. // ping check server ok.
  32. func ping(c *bm.Context) {
  33. }
  34. // this can delete
  35. func howToStart(c *bm.Context) {
  36. out := "[\n {\n\ttitle: 如有问题请联系(企业微信) |&&|,\n\tname: 刘玄(小鱼生)\n },\n {\n\ttitle: 一键初始化项目文档,\n\turl: http://info.bilibili.co/pages/viewpage.action?pageId=7548250\n }\n]"
  37. c.String(0, out)
  38. }