f38f3109c2
We should not check if the mux framework internals work as expected in every handler. The missing parameter error doesn't make sense from the user point of view. This change initializes a proper vars context if the mux fails to do so and delegates specific parameter error checks to the handlers. Signed-off-by: David Calavera <david.calavera@gmail.com> Upstream-commit: 389ce0aae6a303660e591ef80272322ac82854e2 Component: engine
34 lines
821 B
Go
34 lines
821 B
Go
package local
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/docker/docker/api/server/httputils"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
// getContainersByName inspects containers configuration and serializes it as json.
|
|
func (s *router) getContainersByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
|
displaySize := httputils.BoolValue(r, "size")
|
|
|
|
var json interface{}
|
|
var err error
|
|
|
|
version := httputils.VersionFromContext(ctx)
|
|
|
|
switch {
|
|
case version.LessThan("1.20"):
|
|
json, err = s.daemon.ContainerInspectPre120(vars["name"])
|
|
case version.Equal("1.20"):
|
|
json, err = s.daemon.ContainerInspect120(vars["name"])
|
|
default:
|
|
json, err = s.daemon.ContainerInspect(vars["name"], displaySize)
|
|
}
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return httputils.WriteJSON(w, http.StatusOK, json)
|
|
}
|