system.go 889 B

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