Use HTTP 201, 204 response codes in REST API

When creating a new entity on the server respond HTTP 201 Created
with the JSON representation of the entity in the body.

When deleting an existing entity, respond with HTTP 204 No Content,
telling the client there is no more content behind the resources
that was just deleted. This is a hint that a future GET is likely
to return 404 Not Found.

Change-Id: Ia7b3964267fcd55b4abcc49dcd6ba4c61f61fd5d
This commit is contained in:
Shawn O. Pearce
2012-11-27 13:04:21 -08:00
parent 06bfb9030a
commit 8f42f87b21
11 changed files with 168 additions and 51 deletions

View File

@@ -18,6 +18,7 @@ import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.client.Change;
@@ -71,7 +72,7 @@ class DeleteReviewer implements RestModifyView<ReviewerResource, Input> {
} finally {
db.rollback();
}
return new Object();
return Response.none();
}
private Iterable<PatchSetApproval> approvals(ReviewDb db,