github.com/getong/docker@v1.13.1/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  type validationError struct {
     9  	error
    10  }
    11  
    12  func (validationError) IsValidationError() bool {
    13  	return true
    14  }
    15  
    16  // containerRouter is a router to talk with the container controller
    17  type containerRouter struct {
    18  	backend Backend
    19  	decoder httputils.ContainerDecoder
    20  	routes  []router.Route
    21  }
    22  
    23  // NewRouter initializes a new container router
    24  func NewRouter(b Backend, decoder httputils.ContainerDecoder) router.Router {
    25  	r := &containerRouter{
    26  		backend: b,
    27  		decoder: decoder,
    28  	}
    29  	r.initRoutes()
    30  	return r
    31  }
    32  
    33  // Routes returns the available routes to the container controller
    34  func (r *containerRouter) Routes() []router.Route {
    35  	return r.routes
    36  }
    37  
    38  // initRoutes initializes the routes in container router
    39  func (r *containerRouter) initRoutes() {
    40  	r.routes = []router.Route{
    41  		// HEAD
    42  		router.NewHeadRoute("/containers/{name:.*}/archive", r.headContainersArchive),
    43  		// GET
    44  		router.NewGetRoute("/containers/json", r.getContainersJSON),
    45  		router.NewGetRoute("/containers/{name:.*}/export", r.getContainersExport),
    46  		router.NewGetRoute("/containers/{name:.*}/changes", r.getContainersChanges),
    47  		router.NewGetRoute("/containers/{name:.*}/json", r.getContainersByName),
    48  		router.NewGetRoute("/containers/{name:.*}/top", r.getContainersTop),
    49  		router.Cancellable(router.NewGetRoute("/containers/{name:.*}/logs", r.getContainersLogs)),
    50  		router.Cancellable(router.NewGetRoute("/containers/{name:.*}/stats", r.getContainersStats)),
    51  		router.NewGetRoute("/containers/{name:.*}/attach/ws", r.wsContainersAttach),
    52  		router.NewGetRoute("/exec/{id:.*}/json", r.getExecByID),
    53  		router.NewGetRoute("/containers/{name:.*}/archive", r.getContainersArchive),
    54  		// POST
    55  		router.NewPostRoute("/containers/create", r.postContainersCreate),
    56  		router.NewPostRoute("/containers/{name:.*}/kill", r.postContainersKill),
    57  		router.NewPostRoute("/containers/{name:.*}/pause", r.postContainersPause),
    58  		router.NewPostRoute("/containers/{name:.*}/unpause", r.postContainersUnpause),
    59  		router.NewPostRoute("/containers/{name:.*}/restart", r.postContainersRestart),
    60  		router.NewPostRoute("/containers/{name:.*}/start", r.postContainersStart),
    61  		router.NewPostRoute("/containers/{name:.*}/stop", r.postContainersStop),
    62  		router.NewPostRoute("/containers/{name:.*}/wait", r.postContainersWait),
    63  		router.NewPostRoute("/containers/{name:.*}/resize", r.postContainersResize),
    64  		router.NewPostRoute("/containers/{name:.*}/attach", r.postContainersAttach),
    65  		router.NewPostRoute("/containers/{name:.*}/copy", r.postContainersCopy), // Deprecated since 1.8, Errors out since 1.12
    66  		router.NewPostRoute("/containers/{name:.*}/exec", r.postContainerExecCreate),
    67  		router.NewPostRoute("/exec/{name:.*}/start", r.postContainerExecStart),
    68  		router.NewPostRoute("/exec/{name:.*}/resize", r.postContainerExecResize),
    69  		router.NewPostRoute("/containers/{name:.*}/rename", r.postContainerRename),
    70  		router.NewPostRoute("/containers/{name:.*}/update", r.postContainerUpdate),
    71  		router.NewPostRoute("/containers/prune", r.postContainersPrune),
    72  		// PUT
    73  		router.NewPutRoute("/containers/{name:.*}/archive", r.putContainersArchive),
    74  		// DELETE
    75  		router.NewDeleteRoute("/containers/{name:.*}", r.deleteContainers),
    76  	}
    77  }