use of io.vertx.ext.web.client.WebClient in project vertx-examples by vert-x3.
the class Client method start.
@Override
public void start() throws Exception {
WebClient client = WebClient.create(vertx);
client.get(8080, "localhost", "/").send(ar -> {
if (ar.succeeded()) {
HttpResponse<Buffer> response = ar.result();
System.out.println("Got HTTP response with status " + response.statusCode() + " with data " + response.body().toString("ISO-8859-1"));
} else {
ar.cause().printStackTrace();
}
});
}
use of io.vertx.ext.web.client.WebClient in project vertx-examples by vert-x3.
the class Client method start.
@Override
public void start() throws Exception {
WebClient client = WebClient.create(vertx);
client.get(8080, "localhost", "/").as(BodyCodec.json(User.class)).send(ar -> {
if (ar.succeeded()) {
HttpResponse<User> response = ar.result();
System.out.println("Got HTTP response body");
User user = response.body();
System.out.println("FirstName " + user.firstName);
System.out.println("LastName " + user.lastName);
System.out.println("Male " + user.male);
} else {
ar.cause().printStackTrace();
}
});
}
use of io.vertx.ext.web.client.WebClient in project vertx-examples by vert-x3.
the class Client method start.
@Override
public void start() throws Exception {
WebClient client = WebClient.create(vertx);
MultiMap form = MultiMap.caseInsensitiveMultiMap();
form.add("firstName", "Dale");
form.add("lastName", "Cooper");
form.add("male", "true");
client.post(8080, "localhost", "/").sendForm(form, ar -> {
if (ar.succeeded()) {
HttpResponse<Buffer> response = ar.result();
System.out.println("Got HTTP response with status " + response.statusCode());
} else {
ar.cause().printStackTrace();
}
});
}
use of io.vertx.ext.web.client.WebClient in project vertx-examples by vert-x3.
the class Client method start.
@Override
public void start() throws Exception {
WebClient client = WebClient.create(vertx);
Buffer body = Buffer.buffer("Hello World");
client.put(8080, "localhost", "/").sendBuffer(body, ar -> {
if (ar.succeeded()) {
HttpResponse<Buffer> response = ar.result();
System.out.println("Got HTTP response with status " + response.statusCode());
} else {
ar.cause().printStackTrace();
}
});
}
use of io.vertx.ext.web.client.WebClient in project vertx-examples by vert-x3.
the class Client method start.
@Override
public void start() throws Exception {
WebClient client = WebClient.create(vertx);
JsonObject user = new JsonObject().put("firstName", "Dale").put("lastName", "Cooper").put("male", true);
client.put(8080, "localhost", "/").sendJson(user, ar -> {
if (ar.succeeded()) {
HttpResponse<Buffer> response = ar.result();
System.out.println("Got HTTP response with status " + response.statusCode());
} else {
ar.cause().printStackTrace();
}
});
}
Aggregations