Skip to content

Commit

Permalink
Index must be done with PUT, not POST nowadays.
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Dec 9, 2024
1 parent 7b09b54 commit 6dad20a
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,25 @@ public final ObjectNode post(String path, ObjectNode request, Consumer<Request>.
}

@SafeVarargs
public final ObjectNode postEntity(String path, HttpEntity entity, Consumer<Request>... consumers) {
public final ObjectNode put(String path, ObjectNode request, Consumer<Request>... consumers) {
return putEntity(path, entity(request), consumers);
}

public final ObjectNode postEntity(String path, HttpEntity entity, Consumer<Request>... consumers)
{
return sendEntity(POST, path, entity, consumers);
}

public final ObjectNode putEntity(String path, HttpEntity entity, Consumer<Request>... consumers)
{
return sendEntity(PUT, path, entity, consumers);
}

@SafeVarargs
public final ObjectNode sendEntity(String method, String path, HttpEntity entity, Consumer<Request>... consumers) {
try {

Request req = new Request(POST, path);
Request req = new Request(method, path);
req.setEntity(entity);
for (Consumer<Request> c : consumers) {
c.accept(req);
Expand Down Expand Up @@ -679,7 +694,7 @@ public ObjectNode index(String id, byte[] o) {
public ObjectNode index(String id, Object o, Consumer<ObjectNode> sourceConsumer) {
ObjectNode jsonNode = objectMapper.valueToTree(o);
sourceConsumer.accept(jsonNode);
return post(indexPath(id), jsonNode);
return put(indexPath(id), jsonNode);
}


Expand Down

0 comments on commit 6dad20a

Please sign in to comment.