This commit is contained in:
Victor Vieux 2014-11-20 18:52:15 +00:00
parent 9bf438ec64
commit e63e0f3956
2 changed files with 18 additions and 3 deletions

View File

@ -137,6 +137,21 @@ func postContainersStart(c *context, w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "{%q:%q}", "Id", container.Id)
}
// POST /containers/{name:.*}/kill
func postContainerKill(c *context, 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.Kill(r.Form.Get("signal")); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
fmt.Fprintf(w, "{%q:%q}", "Id", container.Id)
}
// POST /containers/{name:.*}/pause
func postContainerPause(c *context, w http.ResponseWriter, r *http.Request) {
name := mux.Vars(r)["name"]
@ -268,7 +283,7 @@ func createRouter(c *context, enableCors bool) (*mux.Router, error) {
"/images/{name:.*}/push": notImplementedHandler,
"/images/{name:.*}/tag": notImplementedHandler,
"/containers/create": postContainersCreate,
"/containers/{name:.*}/kill": notImplementedHandler,
"/containers/{name:.*}/kill": postContainerKill,
"/containers/{name:.*}/pause": postContainerPause,
"/containers/{name:.*}/unpause": postContainerUnpause,
"/containers/{name:.*}/restart": notImplementedHandler,

View File

@ -17,8 +17,8 @@ func (c *Container) Start() error {
return c.node.client.StartContainer(c.Id, nil)
}
func (c *Container) Kill(sig int) error {
return c.node.client.KillContainer(c.Id)
func (c *Container) Kill(signal string) error {
return c.node.client.KillContainer(c.Id, signal)
}
func (c *Container) Stop() error {