system.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package system // import "github.com/docker/docker/api/server/router/system"
  2. import (
  3. "github.com/docker/docker/api/server/router"
  4. "github.com/docker/docker/builder/fscache"
  5. "github.com/docker/docker/daemon/cluster"
  6. )
  7. // systemRouter provides information about the Docker system overall.
  8. // It gathers information about host, daemon and container events.
  9. type systemRouter struct {
  10. backend Backend
  11. cluster *cluster.Cluster
  12. routes []router.Route
  13. builder *fscache.FSCache
  14. }
  15. // NewRouter initializes a new system router
  16. func NewRouter(b Backend, c *cluster.Cluster, fscache *fscache.FSCache) router.Router {
  17. r := &systemRouter{
  18. backend: b,
  19. cluster: c,
  20. builder: fscache,
  21. }
  22. r.routes = []router.Route{
  23. router.NewOptionsRoute("/{anyroute:.*}", optionsHandler),
  24. router.NewGetRoute("/_ping", pingHandler),
  25. router.NewGetRoute("/events", r.getEvents, router.WithCancel),
  26. router.NewGetRoute("/info", r.getInfo),
  27. router.NewGetRoute("/version", r.getVersion),
  28. router.NewGetRoute("/system/df", r.getDiskUsage, router.WithCancel),
  29. router.NewPostRoute("/auth", r.postAuth),
  30. }
  31. return r
  32. }
  33. // Routes returns all the API routes dedicated to the docker system
  34. func (s *systemRouter) Routes() []router.Route {
  35. return s.routes
  36. }