Advertisement
shakasu

Untitled

Feb 20th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1.  public void get(WebClient client) {
  2.         client
  3.                 .post(8181, "localhost", "/graphql")
  4.                 .putHeader("Content-Type", "application/json")
  5.                 .sendJsonObject(
  6.                         new JsonObject()
  7.                                 .put("query", "{Book { uuid, book_name, author }}")
  8.                 )
  9.                 .onSuccess(res -> {
  10.                     if (res.statusCode() == 200 &&
  11.                             res.getHeader("content-type").equals("application/json;charset=utf-8")) {
  12.                         JsonObject body = res.bodyAsJsonObject();
  13.                         post(client, body);
  14.                     }
  15.                 });
  16.     }
  17.  
  18.     public void post(WebClient client, JsonObject body) {
  19.         client
  20.                 .post(8181, "localhost", "/http")
  21.                 .putHeader("Content-Type", "application/json")
  22.                 .putHeader("auth-token", "9f226286-e0d8-4125-ad43-b123b4e464da")
  23.                 .sendJsonObject(body)
  24.                 .onSuccess(res -> {
  25.                     //todo
  26.                 });
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement