system.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
  2. //go:build go1.19
  3. package system // import "github.com/docker/docker/api/server/router/system"
  4. import (
  5. "github.com/docker/docker/api/server/router"
  6. buildkit "github.com/docker/docker/builder/builder-next"
  7. )
  8. // systemRouter provides information about the Docker system overall.
  9. // It gathers information about host, daemon and container events.
  10. type systemRouter struct {
  11. backend Backend
  12. cluster ClusterBackend
  13. routes []router.Route
  14. builder *buildkit.Builder
  15. features *map[string]bool
  16. }
  17. // NewRouter initializes a new system router
  18. func NewRouter(b Backend, c ClusterBackend, builder *buildkit.Builder, features *map[string]bool) router.Router {
  19. r := &systemRouter{
  20. backend: b,
  21. cluster: c,
  22. builder: builder,
  23. features: features,
  24. }
  25. r.routes = []router.Route{
  26. router.NewOptionsRoute("/{anyroute:.*}", optionsHandler),
  27. router.NewGetRoute("/_ping", r.pingHandler),
  28. router.NewHeadRoute("/_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. }