1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/api/server/router/container/inspect.go
Dong Chen fa8d96ebe2 Add container package for container APIs.
Signed-off-by: Dong Chen <dongluo.chen@docker.com>
2015-11-24 14:03:07 -05:00

33 lines
837 B
Go

package container
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 *containerRouter) 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.backend.ContainerInspectPre120(vars["name"])
case version.Equal("1.20"):
json, err = s.backend.ContainerInspect120(vars["name"])
default:
json, err = s.backend.ContainerInspect(vars["name"], displaySize)
}
if err != nil {
return err
}
return httputils.WriteJSON(w, http.StatusOK, json)
}