Skip to content

Commit

Permalink
Added PATCH support to view rest handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhly-etc committed Mar 29, 2017
1 parent 9cfa58d commit 7dcb555
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 17 additions & 0 deletions UnitTests/HttpInterface/api-view-spec-noncluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,23 @@
doc2.parsed_response['extra'].should eq(nil)
end

it "accept updates via PATCH as well" do
cmd1 = api + '/abc/properties'
body1 = <<-JSON
{ "level": "TRACE" }
JSON
doc1 = ArangoDB.log_patch("#{prefix}-accept-patch", cmd1, :body => body1)
doc1.code.should eq(200)
doc1.headers['content-type'].should eq("application/json; charset=utf-8")
doc1.parsed_response['level'].should eq("TRACE")

cmd2 = api + '/abc/properties'
doc2 = ArangoDB.log_get("#{prefix}-accept-patch", cmd2)
doc2.code.should eq(200)
doc2.headers['content-type'].should eq("application/json; charset=utf-8")
doc2.parsed_response['level'].should eq("TRACE")
end

end

end
Expand Down
7 changes: 6 additions & 1 deletion arangod/RestHandler/RestViewHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ RestStatus RestViewHandler::execute() {
return RestStatus::DONE;
}

if (type == rest::RequestType::PATCH) {
modifyView();
return RestStatus::DONE;
}

if (type == rest::RequestType::DELETE_REQ) {
deleteView();
return RestStatus::DONE;
Expand Down Expand Up @@ -140,7 +145,7 @@ void RestViewHandler::modifyView() {

if ((suffixes.size() != 2) || (suffixes[1] != "properties")) {
generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
"expecting PUT /_api/view/<view-name>/properties");
"expecting [PUT, PATCH] /_api/view/<view-name>/properties");
return;
}

Expand Down

0 comments on commit 7dcb555

Please sign in to comment.