API: docker start support.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2014-11-12 17:54:53 -08:00
parent cd7b9e571c
commit 56729ae150
1 changed files with 15 additions and 1 deletions

View File

@ -88,6 +88,20 @@ func getContainerJSON(c *HttpApiContext, w http.ResponseWriter, r *http.Request)
}
}
// POST /containers/{name:.*}/start
func postContainersStart(c *HttpApiContext, w http.ResponseWriter, r *http.Request) {
name := mux.Vars(r)["name"]
container := c.cluster.Container(name)
if container == nil {
http.Error(w, fmt.Sprintf("Container %s not found", name), http.StatusNotFound)
return
}
if err := container.Start(); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
fmt.Fprintf(w, "{%q:%q}", "Id", container.Id)
}
// DELETE /containers/{name:.*}
func deleteContainer(c *HttpApiContext, w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
@ -170,7 +184,7 @@ func createRouter(c *HttpApiContext) (*mux.Router, error) {
"/containers/{name:.*}/pause": notImplementedHandler,
"/containers/{name:.*}/unpause": notImplementedHandler,
"/containers/{name:.*}/restart": notImplementedHandler,
"/containers/{name:.*}/start": notImplementedHandler,
"/containers/{name:.*}/start": postContainersStart,
"/containers/{name:.*}/stop": notImplementedHandler,
"/containers/{name:.*}/wait": notImplementedHandler,
"/containers/{name:.*}/resize": notImplementedHandler,