Browse code

Merge pull request #24634 from thaJeztah/make-network-name-required

API return network-list if no network-name or id is provided

Vincent Demeester authored on 2016/09/27 17:20:38
Showing 3 changed files
... ...
@@ -31,7 +31,8 @@ func (r *networkRouter) initRoutes() {
31 31
 	r.routes = []router.Route{
32 32
 		// GET
33 33
 		router.NewGetRoute("/networks", r.getNetworksList),
34
-		router.NewGetRoute("/networks/{id:.*}", r.getNetwork),
34
+		router.NewGetRoute("/networks/", r.getNetworksList),
35
+		router.NewGetRoute("/networks/{id:.+}", r.getNetwork),
35 36
 		// POST
36 37
 		router.NewPostRoute("/networks/create", r.postNetworkCreate),
37 38
 		router.NewPostRoute("/networks/{id:.*}/connect", r.postNetworkConnect),
... ...
@@ -59,6 +59,7 @@ func (daemon *Daemon) GetNetworkByID(partialID string) (libnetwork.Network, erro
59 59
 }
60 60
 
61 61
 // GetNetworkByName function returns a network for a given network name.
62
+// If no network name is given, the default network is returned.
62 63
 func (daemon *Daemon) GetNetworkByName(name string) (libnetwork.Network, error) {
63 64
 	c := daemon.netController
64 65
 	if c == nil {
... ...
@@ -125,6 +125,9 @@ This section lists each version from latest to oldest.  Each listing includes a
125 125
 * `POST /containers/create` now takes a `Mounts` field in `HostConfig` which replaces `Binds` and `Volumes`. *note*: `Binds` and `Volumes` are still available but are exclusive with `Mounts`
126 126
 * `POST /build` now performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. Note that this change is _unversioned_ and applied to all API versions.
127 127
 * `POST /build` accepts `cachefrom` parameter to specify images used for build cache.
128
+* `GET /networks/` endpoint now correctly returns a list of *all* networks,
129
+  instead of the default network if a trailing slash is provided, but no `name`
130
+  or `id`.
128 131
 
129 132
 ### v1.24 API changes
130 133