github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/api/server/router/container/container.go (about) 1 package container 2 3 import ( 4 "github.com/docker/docker/api/server/httputils" 5 "github.com/docker/docker/api/server/router" 6 ) 7 8 // containerRouter is a router to talk with the container controller 9 type containerRouter struct { 10 backend Backend 11 decoder httputils.ContainerDecoder 12 routes []router.Route 13 } 14 15 // NewRouter initializes a new container router 16 func NewRouter(b Backend, decoder httputils.ContainerDecoder) router.Router { 17 r := &containerRouter{ 18 backend: b, 19 decoder: decoder, 20 } 21 r.initRoutes() 22 return r 23 } 24 25 // Routes returns the available routes to the container controller 26 func (r *containerRouter) Routes() []router.Route { 27 return r.routes 28 } 29 30 // initRoutes initializes the routes in container router 31 func (r *containerRouter) initRoutes() { 32 r.routes = []router.Route{ 33 // HEAD 34 router.NewHeadRoute("/containers/{name:.*}/archive", r.headContainersArchive), 35 // GET 36 router.NewGetRoute("/containers/json", r.getContainersJSON), 37 router.NewGetRoute("/containers/{name:.*}/export", r.getContainersExport), 38 router.NewGetRoute("/containers/{name:.*}/changes", r.getContainersChanges), 39 router.NewGetRoute("/containers/{name:.*}/json", r.getContainersByName), 40 router.NewGetRoute("/containers/{name:.*}/top", r.getContainersTop), 41 router.Cancellable(router.NewGetRoute("/containers/{name:.*}/logs", r.getContainersLogs)), 42 router.Cancellable(router.NewGetRoute("/containers/{name:.*}/stats", r.getContainersStats)), 43 router.NewGetRoute("/containers/{name:.*}/attach/ws", r.wsContainersAttach), 44 router.NewGetRoute("/exec/{id:.*}/json", r.getExecByID), 45 router.NewGetRoute("/containers/{name:.*}/archive", r.getContainersArchive), 46 // POST 47 router.NewPostRoute("/containers/create", r.postContainersCreate), 48 router.NewPostRoute("/containers/{name:.*}/kill", r.postContainersKill), 49 router.NewPostRoute("/containers/{name:.*}/pause", r.postContainersPause), 50 router.NewPostRoute("/containers/{name:.*}/unpause", r.postContainersUnpause), 51 router.NewPostRoute("/containers/{name:.*}/restart", r.postContainersRestart), 52 router.NewPostRoute("/containers/{name:.*}/start", r.postContainersStart), 53 router.NewPostRoute("/containers/{name:.*}/stop", r.postContainersStop), 54 router.NewPostRoute("/containers/{name:.*}/wait", r.postContainersWait), 55 router.NewPostRoute("/containers/{name:.*}/resize", r.postContainersResize), 56 router.NewPostRoute("/containers/{name:.*}/attach", r.postContainersAttach), 57 router.NewPostRoute("/containers/{name:.*}/copy", r.postContainersCopy), 58 router.NewPostRoute("/containers/{name:.*}/exec", r.postContainerExecCreate), 59 router.NewPostRoute("/exec/{name:.*}/start", r.postContainerExecStart), 60 router.NewPostRoute("/exec/{name:.*}/resize", r.postContainerExecResize), 61 router.NewPostRoute("/containers/{name:.*}/rename", r.postContainerRename), 62 router.NewPostRoute("/containers/{name:.*}/update", r.postContainerUpdate), 63 // PUT 64 router.NewPutRoute("/containers/{name:.*}/archive", r.putContainersArchive), 65 // DELETE 66 router.NewDeleteRoute("/containers/{name:.*}", r.deleteContainers), 67 } 68 }