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