1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

remove useless port endpoint

This commit is contained in:
Victor Vieux 2013-05-08 18:06:43 +02:00
parent 60ddcaa15d
commit 075e1ebb0e
4 changed files with 9 additions and 62 deletions

18
api.go
View file

@ -179,23 +179,6 @@ func getContainersChanges(srv *Server, w http.ResponseWriter, r *http.Request) (
return b, nil
}
func getContainersPort(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
if err := r.ParseForm(); err != nil {
return nil, err
}
vars := mux.Vars(r)
name := vars["name"]
out, err := srv.ContainerPort(name, r.Form.Get("port"))
if err != nil {
return nil, err
}
b, err := json.Marshal(ApiPort{out})
if err != nil {
return nil, err
}
return b, nil
}
func getContainers(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
if err := r.ParseForm(); err != nil {
return nil, err
@ -543,7 +526,6 @@ func ListenAndServe(addr string, srv *Server) error {
"/images/search": getImagesSearch,
"/images/{name:.*}/history": getImagesHistory,
"/containers/{name:.*}/changes": getContainersChanges,
"/containers/{name:.*}/port": getContainersPort,
"/containers": getContainers,
"/images/{name:.*}/json": getImagesByName,
"/containers/{name:.*}/json": getContainersByName,

View file

@ -469,19 +469,22 @@ func CmdPort(args ...string) error {
cmd.Usage()
return nil
}
v := url.Values{}
v.Set("port", cmd.Arg(1))
body, _, err := call("GET", "/containers/"+cmd.Arg(0)+"/port?"+v.Encode(), nil)
body, _, err := call("GET", "/containers/"+cmd.Arg(0)+"/json", nil)
if err != nil {
return err
}
var out ApiPort
var out Container
err = json.Unmarshal(body, &out)
if err != nil {
return err
}
fmt.Println(out.Port)
if frontend, exists := out.NetworkSettings.PortMapping[cmd.Arg(1)]; exists {
fmt.Println(frontend)
} else {
return fmt.Errorf("error: No private port '%s' allocated on %s", cmd.Arg(1), cmd.Arg(0))
}
return nil
}

View file

@ -265,34 +265,6 @@ Export a container
:statuscode 500: server error
Map container's private ports
*****************************
.. http:get:: /containers/(id)/port
Map a private port of container ``id``
**Example request**:
.. sourcecode:: http
GET /containers/4fa6e0f0c678/port?port=80 HTTP/1.1
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
{"Port":"80"}
:query port: the container private port you want to get
:statuscode 200: no error
:statuscode 404: no such container
:statuscode 500: server error
Start a container
*****************

View file

@ -235,16 +235,6 @@ func (srv *Server) ContainerChanges(name string) ([]Change, error) {
return nil, fmt.Errorf("No such container: %s", name)
}
func (srv *Server) ContainerPort(name, privatePort string) (string, error) {
if container := srv.runtime.Get(name); container != nil {
if frontend, exists := container.NetworkSettings.PortMapping[privatePort]; exists {
return frontend, nil
}
return "", fmt.Errorf("No private port '%s' allocated on %s", privatePort, name)
}
return "", fmt.Errorf("No such container: %s", name)
}
func (srv *Server) Containers(all, trunc_cmd, only_ids bool, n int) []ApiContainers {
var outs []ApiContainers = []ApiContainers{} //produce [] when empty instead of 'null'
for i, container := range srv.runtime.List() {