http.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package http
  2. import (
  3. "net/http"
  4. "go-common/app/service/ep/footman/conf"
  5. "go-common/app/service/ep/footman/service"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. var (
  10. srv *service.Service
  11. )
  12. // Init Init.
  13. func Init(c *conf.Config, s *service.Service) {
  14. srv = s
  15. engine := bm.DefaultServer(c.BM)
  16. engine.Ping(ping)
  17. outerRouter(engine)
  18. if err := engine.Start(); err != nil {
  19. log.Error("engine.Start error(%v)", err)
  20. panic(err)
  21. }
  22. }
  23. func outerRouter(e *bm.Engine) {
  24. version := e.Group("/ep/admin/footman/v1")
  25. {
  26. version.GET("/version", getVersion)
  27. bugly := version.Group("/bugly")
  28. {
  29. bugly.GET("/issue/query", queryIssue)
  30. bugly.GET("/issue/save", saveIssue)
  31. bugly.GET("/saveissue", saveIssue)
  32. bugly.GET("/saveissues", saveIssues)
  33. bugly.GET("/updatetoken", updateToken)
  34. }
  35. tapd := version.Group("/tapd")
  36. {
  37. tapd.GET("/file/save", saveFiles)
  38. tapd.GET("/file/story/download", downloadStoryFile)
  39. tapd.GET("/file/change/download", downloadChangeFile)
  40. tapd.GET("/file/iteration/download", downloadIterationFile)
  41. tapd.GET("/file/bug/download", downloadBugFile)
  42. }
  43. bugly2tapd := version.Group("/bugly2tapd")
  44. {
  45. bugly2tapd.GET("/save", saveBugly2Tapd)
  46. bugly2tapd.GET("/status/update", updateBuglyStatusInTapd)
  47. bugly2tapd.GET("/title/update", updateTitleInTapd)
  48. }
  49. }
  50. }
  51. func ping(c *bm.Context) {
  52. if err := srv.Ping(c); err != nil {
  53. log.Error("ping error(%v)", err)
  54. c.AbortWithStatus(http.StatusServiceUnavailable)
  55. }
  56. }
  57. func getVersion(c *bm.Context) {
  58. v := new(struct {
  59. Version string `json:"version"`
  60. })
  61. v.Version = "v.1.5.8.2"
  62. c.JSON(v, nil)
  63. }