2015-12-03 13:11:19 -05:00
|
|
|
package system
|
|
|
|
|
2015-12-30 12:20:41 -05:00
|
|
|
import "github.com/docker/docker/api/server/router"
|
2015-12-03 13:11:19 -05:00
|
|
|
|
2015-12-30 12:20:41 -05:00
|
|
|
// systemRouter provides information about the Docker system overall.
|
|
|
|
// It gathers information about host, daemon and container events.
|
2015-12-03 13:11:19 -05:00
|
|
|
type systemRouter struct {
|
|
|
|
backend Backend
|
|
|
|
routes []router.Route
|
|
|
|
}
|
|
|
|
|
2015-12-30 12:20:41 -05:00
|
|
|
// NewRouter initializes a new system router
|
2015-12-03 13:11:19 -05:00
|
|
|
func NewRouter(b Backend) router.Router {
|
|
|
|
r := &systemRouter{
|
|
|
|
backend: b,
|
|
|
|
}
|
|
|
|
|
|
|
|
r.routes = []router.Route{
|
2015-12-30 12:20:41 -05:00
|
|
|
router.NewOptionsRoute("/{anyroute:.*}", optionsHandler),
|
|
|
|
router.NewGetRoute("/_ping", pingHandler),
|
2016-03-25 14:33:54 -04:00
|
|
|
router.Cancellable(router.NewGetRoute("/events", r.getEvents)),
|
2015-12-30 12:20:41 -05:00
|
|
|
router.NewGetRoute("/info", r.getInfo),
|
|
|
|
router.NewGetRoute("/version", r.getVersion),
|
|
|
|
router.NewPostRoute("/auth", r.postAuth),
|
2015-12-03 13:11:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
2015-12-30 12:20:41 -05:00
|
|
|
// Routes returns all the API routes dedicated to the docker system
|
2015-12-03 13:11:19 -05:00
|
|
|
func (s *systemRouter) Routes() []router.Route {
|
|
|
|
return s.routes
|
|
|
|
}
|