Skip to content

Commit 94c9290

Browse files
committed
1.return status code http.StatusNoContent in deleting network when successful
2.modify docker_api_network_test.go 3.modify docker_remote_api_v1.23.md Signed-off-by: allencloud <allen.sun@daocloud.io>
1 parent 160abfb commit 94c9290

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

api/server/router/network/network_routes.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,14 @@ func (n *networkRouter) postNetworkDisconnect(ctx context.Context, w http.Respon
147147
}
148148

149149
func (n *networkRouter) deleteNetwork(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
150-
return n.backend.DeleteNetwork(vars["id"])
150+
if err := httputils.ParseForm(r); err != nil {
151+
return err
152+
}
153+
if err := n.backend.DeleteNetwork(vars["id"]); err != nil {
154+
return err
155+
}
156+
w.WriteHeader(http.StatusNoContent)
157+
return nil
151158
}
152159

153160
func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {

docs/reference/api/docker_remote_api_v1.23.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,7 +3097,7 @@ JSON Parameters:
30973097
30983098
`POST /networks/(id)/connect`
30993099
3100-
Connects a container to a network
3100+
Connect a container to a network
31013101
31023102
**Example request**:
31033103
@@ -3134,7 +3134,7 @@ JSON Parameters:
31343134
31353135
`POST /networks/(id)/disconnect`
31363136
3137-
Disconnects a container from a network
3137+
Disconnect a container from a network
31383138
31393139
**Example request**:
31403140
@@ -3175,11 +3175,11 @@ Instruct the driver to remove the network (`id`).
31753175
31763176
**Example response**:
31773177
3178-
HTTP/1.1 200 OK
3178+
HTTP/1.1 204 No Content
31793179
31803180
Status Codes
31813181
3182-
- **200** - no error
3182+
- **204** - no error
31833183
- **404** - no such network
31843184
- **500** - server error
31853185

integration-cli/docker_api_network_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,6 @@ func deleteNetwork(c *check.C, id string, shouldSucceed bool) {
332332
c.Assert(status, checker.Not(checker.Equals), http.StatusOK)
333333
return
334334
}
335-
c.Assert(status, checker.Equals, http.StatusOK)
335+
c.Assert(status, checker.Equals, http.StatusNoContent)
336336
c.Assert(err, checker.IsNil)
337337
}

0 commit comments

Comments
 (0)