system.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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/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. features *map[string]bool
  16. }
  17. // NewRouter initializes a new system router
  18. func NewRouter(b Backend, c ClusterBackend, fscache *fscache.FSCache, builder *buildkit.Builder, features *map[string]bool) router.Router {
  19. r := &systemRouter{
  20. backend: b,
  21. cluster: c,
  22. fscache: fscache,
  23. builder: builder,
  24. features: features,
  25. }
  26. r.routes = []router.Route{
  27. router.NewOptionsRoute("/{anyroute:.*}", optionsHandler),
  28. router.NewGetRoute("/_ping", r.pingHandler),
  29. router.NewGetRoute("/events", r.getEvents),
  30. router.NewGetRoute("/info", r.getInfo),
  31. router.NewGetRoute("/version", r.getVersion),
  32. router.NewGetRoute("/system/df", r.getDiskUsage),
  33. router.NewPostRoute("/auth", r.postAuth),
  34. }
  35. return r
  36. }
  37. // Routes returns all the API routes dedicated to the docker system
  38. func (s *systemRouter) Routes() []router.Route {
  39. return s.routes
  40. }