system.go 926 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package system
  2. import (
  3. "github.com/docker/docker/api/server/router"
  4. "github.com/docker/docker/api/server/router/local"
  5. )
  6. // systemRouter is a Router that provides information about
  7. // the Docker system overall. It gathers information about
  8. // host, daemon and container events.
  9. type systemRouter struct {
  10. backend Backend
  11. routes []router.Route
  12. }
  13. // NewRouter initializes a new systemRouter
  14. func NewRouter(b Backend) router.Router {
  15. r := &systemRouter{
  16. backend: b,
  17. }
  18. r.routes = []router.Route{
  19. local.NewOptionsRoute("/", optionsHandler),
  20. local.NewGetRoute("/_ping", pingHandler),
  21. local.NewGetRoute("/events", r.getEvents),
  22. local.NewGetRoute("/info", r.getInfo),
  23. local.NewGetRoute("/version", r.getVersion),
  24. local.NewPostRoute("/auth", r.postAuth),
  25. }
  26. return r
  27. }
  28. // Routes return all the API routes dedicated to the docker system.
  29. func (s *systemRouter) Routes() []router.Route {
  30. return s.routes
  31. }