diff --git a/api/handlers.go b/api/handlers.go index 1da5ab2eee..9930c48de1 100644 --- a/api/handlers.go +++ b/api/handlers.go @@ -68,20 +68,6 @@ func getVersion(c *context, w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(version) } -// GET /images/{name:.*}/get -func getImage(c *context, w http.ResponseWriter, r *http.Request) { - name := mux.Vars(r)["name"] - - for _, image := range c.cluster.Images() { - if len(strings.SplitN(name, ":", 2)) == 2 && image.Match(name, true) || - len(strings.SplitN(name, ":", 2)) == 1 && image.Match(name, false) { - proxy(c.tlsConfig, image.Engine.Addr, w, r) - return - } - } - httpError(w, fmt.Sprintf("No such image: %s", name), http.StatusNotFound) -} - // GET /images/get func getImages(c *context, w http.ResponseWriter, r *http.Request) { if err := r.ParseForm(); err != nil { @@ -577,6 +563,20 @@ func proxyImage(c *context, w http.ResponseWriter, r *http.Request) { httpError(w, fmt.Sprintf("No such image: %s", name), http.StatusNotFound) } +// Proxy a request to the right node +func proxyImageTagOptional(c *context, w http.ResponseWriter, r *http.Request) { + name := mux.Vars(r)["name"] + + for _, image := range c.cluster.Images() { + if len(strings.SplitN(name, ":", 2)) == 2 && image.Match(name, true) || + len(strings.SplitN(name, ":", 2)) == 1 && image.Match(name, false) { + proxy(c.tlsConfig, image.Engine.Addr, w, r) + return + } + } + httpError(w, fmt.Sprintf("No such image: %s", name), http.StatusNotFound) +} + // Proxy a request to the right node and force refresh func proxyImageAndForceRefresh(c *context, w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] diff --git a/api/primary.go b/api/primary.go index ca44462267..a3df99c78b 100644 --- a/api/primary.go +++ b/api/primary.go @@ -30,7 +30,7 @@ var routes = map[string]map[string]handler{ "/images/viz": notImplementedHandler, "/images/search": proxyRandom, "/images/get": getImages, - "/images/{name:.*}/get": getImage, + "/images/{name:.*}/get": proxyImageTagOptional, "/images/{name:.*}/history": proxyImage, "/images/{name:.*}/json": proxyImage, "/containers/ps": getContainersJSON, @@ -50,7 +50,7 @@ var routes = map[string]map[string]handler{ "/build": proxyRandomAndForceRefresh, "/images/create": postImagesCreate, "/images/load": postImagesLoad, - "/images/{name:.*}/push": proxyImage, + "/images/{name:.*}/push": proxyImageTagOptional, "/images/{name:.*}/tag": proxyImageAndForceRefresh, "/containers/create": postContainersCreate, "/containers/{name:.*}/kill": proxyContainerAndForceRefresh,