http.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package http
  2. import (
  3. "go-common/app/job/main/videoup-report/conf"
  4. "go-common/app/job/main/videoup-report/service"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. "net/http"
  8. )
  9. var (
  10. vdaSvc *service.Service
  11. )
  12. // Init http server
  13. func Init(c *conf.Config, s *service.Service) {
  14. vdaSvc = s
  15. // init internal router
  16. engine := bm.DefaultServer(c.BM)
  17. innerRouter(engine)
  18. // init internal server
  19. if err := engine.Start(); err != nil {
  20. log.Error("engine.Start error(%v)", err)
  21. panic(err)
  22. }
  23. }
  24. // innerRouter
  25. func innerRouter(e *bm.Engine) {
  26. e.GET("/monitor/ping", ping)
  27. g := e.Group("/x/videoup/report")
  28. {
  29. task := g.Group("/task")
  30. {
  31. task.GET("/tooks", taskTooks)
  32. }
  33. video := g.Group("/video")
  34. {
  35. video.GET("/audit", videoAudit)
  36. video.GET("/xcode", videoXcode)
  37. }
  38. archive := g.Group("/archive")
  39. {
  40. archive.GET("/movetype", moveType)
  41. archive.GET("/roundflow", roundFlow)
  42. }
  43. }
  44. }
  45. // ping check server ok.
  46. func ping(c *bm.Context) {
  47. var err error
  48. if err = vdaSvc.Ping(c); err != nil {
  49. log.Error("videoup-report-job ping error(%v)", err)
  50. c.AbortWithStatus(http.StatusServiceUnavailable)
  51. }
  52. }