Browse code

Merge pull request #20977 from allencloud/fix-delete-response-status-code

return status code http.StatusNoContent in deleting network when OK

Brian Goff authored on 2016/03/14 00:30:32
Showing 3 changed files
... ...
@@ -147,7 +147,14 @@ func (n *networkRouter) postNetworkDisconnect(ctx context.Context, w http.Respon
147 147
 }
148 148
 
149 149
 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
151 158
 }
152 159
 
153 160
 func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {
... ...
@@ -3125,7 +3125,7 @@ JSON Parameters:
3125 3125
 
3126 3126
 `POST /networks/(id)/connect`
3127 3127
 
3128
-Connects a container to a network
3128
+Connect a container to a network
3129 3129
 
3130 3130
 **Example request**:
3131 3131
 
... ...
@@ -3162,7 +3162,7 @@ JSON Parameters:
3162 3162
 
3163 3163
 `POST /networks/(id)/disconnect`
3164 3164
 
3165
-Disconnects a container from a network
3165
+Disconnect a container from a network
3166 3166
 
3167 3167
 **Example request**:
3168 3168
 
... ...
@@ -3203,11 +3203,11 @@ Instruct the driver to remove the network (`id`).
3203 3203
 
3204 3204
 **Example response**:
3205 3205
 
3206
-    HTTP/1.1 200 OK
3206
+    HTTP/1.1 204 No Content
3207 3207
 
3208 3208
 Status Codes
3209 3209
 
3210
--   **200** - no error
3210
+-   **204** - no error
3211 3211
 -   **404** - no such network
3212 3212
 -   **500** - server error
3213 3213
 
... ...
@@ -332,6 +332,6 @@ func deleteNetwork(c *check.C, id string, shouldSucceed bool) {
332 332
 		c.Assert(status, checker.Not(checker.Equals), http.StatusOK)
333 333
 		return
334 334
 	}
335
-	c.Assert(status, checker.Equals, http.StatusOK)
335
+	c.Assert(status, checker.Equals, http.StatusNoContent)
336 336
 	c.Assert(err, checker.IsNil)
337 337
 }