mirror of https://github.com/docker/docs.git
Add start to apiserver
Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This commit is contained in:
parent
41f3776cf8
commit
9b7ad0bb63
|
@ -61,6 +61,27 @@ func getContainersJSON(out beam.Sender, version version.Version, w http.Response
|
||||||
return writeJSON(w, http.StatusOK, names)
|
return writeJSON(w, http.StatusOK, names)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func postContainersStart(out beam.Sender, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
|
if vars == nil {
|
||||||
|
return fmt.Errorf("Missing parameter")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: r.Body
|
||||||
|
|
||||||
|
name := vars["name"]
|
||||||
|
_, containerOut, err := beam.Obj(out).Attach(name)
|
||||||
|
container := beam.Obj(containerOut)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := container.Start(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func createRouter(out beam.Sender) (*mux.Router, error) {
|
func createRouter(out beam.Sender) (*mux.Router, error) {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
m := map[string]map[string]HttpApiFunc{
|
m := map[string]map[string]HttpApiFunc{
|
||||||
|
@ -68,7 +89,9 @@ func createRouter(out beam.Sender) (*mux.Router, error) {
|
||||||
"/_ping": ping,
|
"/_ping": ping,
|
||||||
"/containers/json": getContainersJSON,
|
"/containers/json": getContainersJSON,
|
||||||
},
|
},
|
||||||
"POST": {},
|
"POST": {
|
||||||
|
"/containers/{name:.*}/start": postContainersStart,
|
||||||
|
},
|
||||||
"DELETE": {},
|
"DELETE": {},
|
||||||
"OPTIONS": {},
|
"OPTIONS": {},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue