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. )
  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 *buildkit.Builder
  13. features *map[string]bool
  14. }
  15. // NewRouter initializes a new system router
  16. func NewRouter(b Backend, c ClusterBackend, builder *buildkit.Builder, features *map[string]bool) router.Router {
  17. r := &systemRouter{
  18. backend: b,
  19. cluster: c,
  20. builder: builder,
  21. features: features,
  22. }
  23. r.routes = []router.Route{
  24. router.NewOptionsRoute("/{anyroute:.*}", optionsHandler),
  25. router.NewGetRoute("/_ping", r.pingHandler),
  26. router.NewHeadRoute("/_ping", r.pingHandler),
  27. router.NewGetRoute("/events", r.getEvents),
  28. router.NewGetRoute("/info", r.getInfo),
  29. router.NewGetRoute("/version", r.getVersion),
  30. router.NewGetRoute("/system/df", r.getDiskUsage),
  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. }