Advertisement
shakasu

Untitled

Mar 3rd, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. private void buildPostRoute(TarantoolClient tarantoolClient) {
  2.         router.post("/post")
  3.                 .handler(rc -> tarantoolClient.graphql(rc.getBodyAsJson())
  4.                         .onSuccess(httpResp -> {
  5.                             if (
  6.                                     httpResp.statusCode() == 200
  7.                                             && !httpResp.getHeader("content-type").contentEquals("application/json")
  8.                             ) {
  9.                                 rc.end(httpResp.bodyAsBuffer());
  10.                             } else {
  11.                                 log.error("GraphQL query not found");
  12.                                 rc.response()
  13.                                         .setStatusCode(400)
  14.                                         .putHeader("Content-Type", "application/json")
  15.                                         .end(
  16.                                                 new JsonObject()
  17.                                                         .put("message", httpResp.statusMessage())
  18.                                                         .toBuffer()
  19.                                         );
  20.                             }
  21.                         })
  22.                 );
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement