github.com/rish1988/moby@v25.0.2+incompatible/api/server/router/system/system.go (about) 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 4 package system // import "github.com/docker/docker/api/server/router/system" 5 6 import ( 7 "github.com/docker/docker/api/server/router" 8 "github.com/docker/docker/api/types/system" 9 buildkit "github.com/docker/docker/builder/builder-next" 10 "resenje.org/singleflight" 11 ) 12 13 // systemRouter provides information about the Docker system overall. 14 // It gathers information about host, daemon and container events. 15 type systemRouter struct { 16 backend Backend 17 cluster ClusterBackend 18 routes []router.Route 19 builder *buildkit.Builder 20 features func() map[string]bool 21 22 // collectSystemInfo is a single-flight for the /info endpoint, 23 // unique per API version (as different API versions may return 24 // a different API response). 25 collectSystemInfo singleflight.Group[string, *system.Info] 26 } 27 28 // NewRouter initializes a new system router 29 func NewRouter(b Backend, c ClusterBackend, builder *buildkit.Builder, features func() map[string]bool) router.Router { 30 r := &systemRouter{ 31 backend: b, 32 cluster: c, 33 builder: builder, 34 features: features, 35 } 36 37 r.routes = []router.Route{ 38 router.NewOptionsRoute("/{anyroute:.*}", optionsHandler), 39 router.NewGetRoute("/_ping", r.pingHandler), 40 router.NewHeadRoute("/_ping", r.pingHandler), 41 router.NewGetRoute("/events", r.getEvents), 42 router.NewGetRoute("/info", r.getInfo), 43 router.NewGetRoute("/version", r.getVersion), 44 router.NewGetRoute("/system/df", r.getDiskUsage), 45 router.NewPostRoute("/auth", r.postAuth), 46 } 47 48 return r 49 } 50 51 // Routes returns all the API routes dedicated to the docker system 52 func (s *systemRouter) Routes() []router.Route { 53 return s.routes 54 }