system.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package system // import "github.com/docker/docker/api/server/router/system"
  2. import (
  3. "github.com/docker/docker/api/server/router"
  4. buildkit "github.com/docker/docker/builder/builder-next"
  5. "github.com/docker/docker/builder/fscache"
  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 ClusterBackend
  12. routes []router.Route
  13. fscache *fscache.FSCache // legacy
  14. builder *buildkit.Builder
  15. }
  16. // NewRouter initializes a new system router
  17. func NewRouter(b Backend, c ClusterBackend, fscache *fscache.FSCache, builder *buildkit.Builder) router.Router {
  18. r := &systemRouter{
  19. backend: b,
  20. cluster: c,
  21. fscache: fscache,
  22. builder: builder,
  23. }
  24. r.routes = []router.Route{
  25. router.NewOptionsRoute("/{anyroute:.*}", optionsHandler),
  26. router.NewGetRoute("/_ping", pingHandler),
  27. router.NewGetRoute("/events", r.getEvents, router.WithCancel),
  28. router.NewGetRoute("/info", r.getInfo),
  29. router.NewGetRoute("/version", r.getVersion),
  30. router.NewGetRoute("/system/df", r.getDiskUsage, router.WithCancel),
  31. router.NewPostRoute("/auth", r.postAuth),
  32. }
  33. return r
  34. }
  35. // Routes returns all the API routes dedicated to the docker system
  36. func (s *systemRouter) Routes() []router.Route {
  37. return s.routes
  38. }