Skip to content

Commit

Permalink
1.return status code http.StatusNoContent in deleting network when su…
Browse files Browse the repository at this point in the history
…ccessful

2.modify docker_api_network_test.go
3.modify docker_remote_api_v1.23.md

Signed-off-by: allencloud <allen.sun@daocloud.io>
  • Loading branch information
allencloud committed Mar 9, 2016
1 parent 160abfb commit 94c9290
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion api/server/router/network/network_routes.go
Expand Up @@ -147,7 +147,14 @@ func (n *networkRouter) postNetworkDisconnect(ctx context.Context, w http.Respon
}

func (n *networkRouter) deleteNetwork(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
return n.backend.DeleteNetwork(vars["id"])
if err := httputils.ParseForm(r); err != nil {
return err
}
if err := n.backend.DeleteNetwork(vars["id"]); err != nil {
return err
}
w.WriteHeader(http.StatusNoContent)
return nil
}

func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/api/docker_remote_api_v1.23.md
Expand Up @@ -3097,7 +3097,7 @@ JSON Parameters:

`POST /networks/(id)/connect`

Connects a container to a network
Connect a container to a network

**Example request**:

Expand Down Expand Up @@ -3134,7 +3134,7 @@ JSON Parameters:

`POST /networks/(id)/disconnect`

Disconnects a container from a network
Disconnect a container from a network

**Example request**:

Expand Down Expand Up @@ -3175,11 +3175,11 @@ Instruct the driver to remove the network (`id`).

**Example response**:

HTTP/1.1 200 OK
HTTP/1.1 204 No Content

Status Codes

- **200** - no error
- **204** - no error
- **404** - no such network
- **500** - server error

Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_api_network_test.go
Expand Up @@ -332,6 +332,6 @@ func deleteNetwork(c *check.C, id string, shouldSucceed bool) {
c.Assert(status, checker.Not(checker.Equals), http.StatusOK)
return
}
c.Assert(status, checker.Equals, http.StatusOK)
c.Assert(status, checker.Equals, http.StatusNoContent)
c.Assert(err, checker.IsNil)
}

0 comments on commit 94c9290

Please sign in to comment.