system.go 1.2 KB

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