system.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package system
  2. import (
  3. "github.com/docker/docker/api/server/router"
  4. "github.com/docker/docker/daemon/cluster"
  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. clusterProvider *cluster.Cluster
  11. routes []router.Route
  12. }
  13. // NewRouter initializes a new system router
  14. func NewRouter(b Backend, c *cluster.Cluster) router.Router {
  15. r := &systemRouter{
  16. backend: b,
  17. clusterProvider: c,
  18. }
  19. r.routes = []router.Route{
  20. router.NewOptionsRoute("/{anyroute:.*}", optionsHandler),
  21. router.NewGetRoute("/_ping", pingHandler),
  22. router.Cancellable(router.NewGetRoute("/events", r.getEvents)),
  23. router.NewGetRoute("/info", r.getInfo),
  24. router.NewGetRoute("/version", r.getVersion),
  25. router.NewPostRoute("/auth", r.postAuth),
  26. }
  27. return r
  28. }
  29. // Routes returns all the API routes dedicated to the docker system
  30. func (s *systemRouter) Routes() []router.Route {
  31. return s.routes
  32. }