diff --git a/api/README.md b/api/README.md index d36f1af797..c3c6f9244c 100644 --- a/api/README.md +++ b/api/README.md @@ -16,7 +16,6 @@ Some endpoints have not yet been implemented and will return a 404 error. GET "/images/get" GET "/containers/{name:.*}/attach/ws" -POST "/commit" POST "/build" POST "/images/load" POST "/images/{name:.*}/push" diff --git a/api/api.go b/api/api.go index 84fd5a84c7..c3ca8d0631 100644 --- a/api/api.go +++ b/api/api.go @@ -423,6 +423,29 @@ func proxyRandom(c *context, w http.ResponseWriter, r *http.Request) { } } +// POST /commit +func postCommit(c *context, w http.ResponseWriter, r *http.Request) { + if err := r.ParseForm(); err != nil { + httpError(w, err.Error(), http.StatusInternalServerError) + return + } + + vars := make(map[string]string) + vars["name"] = r.Form.Get("container") + + // get container + container, err := getContainerFromVars(c, vars) + if err != nil { + httpError(w, err.Error(), http.StatusNotFound) + return + } + + // proxy commit request to the right node + if err := proxy(c.tlsConfig, container.Node.Addr(), w, r); err != nil { + httpError(w, err.Error(), http.StatusInternalServerError) + } +} + // Proxy a hijack request to the right node func proxyHijack(c *context, w http.ResponseWriter, r *http.Request) { container, err := getContainerFromVars(c, mux.Vars(r)) @@ -484,7 +507,7 @@ func createRouter(c *context, enableCors bool) *mux.Router { }, "POST": { "/auth": proxyRandom, - "/commit": notImplementedHandler, + "/commit": postCommit, "/build": notImplementedHandler, "/images/create": postImagesCreate, "/images/load": notImplementedHandler,