github.com/ncdc/docker@v0.10.1-0.20160129113957-6c6729ef5b74/api/server/router/container/container.go (about)

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