github.com/goern/docker@v1.9.0-rc1/api/server/router/local/inspect.go (about) 1 package local 2 3 import ( 4 "fmt" 5 "net/http" 6 7 "github.com/docker/docker/api/server/httputils" 8 "golang.org/x/net/context" 9 ) 10 11 // getContainersByName inspects containers configuration and serializes it as json. 12 func (s *router) getContainersByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { 13 displaySize := httputils.BoolValue(r, "size") 14 if vars == nil { 15 return fmt.Errorf("Missing parameter") 16 } 17 18 var json interface{} 19 var err error 20 21 version := httputils.VersionFromContext(ctx) 22 23 switch { 24 case version.LessThan("1.20"): 25 json, err = s.daemon.ContainerInspectPre120(vars["name"]) 26 case version.Equal("1.20"): 27 json, err = s.daemon.ContainerInspect120(vars["name"]) 28 default: 29 json, err = s.daemon.ContainerInspect(vars["name"], displaySize) 30 } 31 32 if err != nil { 33 return err 34 } 35 36 return httputils.WriteJSON(w, http.StatusOK, json) 37 }