@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(); } }); } }
@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(); } }); } }
@Override public void start() throws Exception { WebClient client = WebClient.create(vertx); User user = new User(); user.firstName = "Dale"; user.lastName = "Cooper"; user.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(); } }); } }
@Override public void start() throws Exception { WebClient client = WebClient.create(vertx); client.get(8080, "localhost", "/") .as(BodyCodec.jsonObject()) .send(ar -> { if (ar.succeeded()) { HttpResponse<JsonObject> response = ar.result(); System.out.println("Got HTTP response body"); System.out.println(response.body().encodePrettily()); } else { ar.cause().printStackTrace(); } }); } }
@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(); } }); } }
@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(); } }); } }
@Override public void start() throws Exception { WebClient client = WebClient.create(vertx); client.get(8080, "localhost", "/") .addQueryParam("firstName", "Dale") .addQueryParam("lastName", "Cooper") .addQueryParam("male", "true") .send(ar -> { if (ar.succeeded()) { HttpResponse<Buffer> response = ar.result(); System.out.println("Got HTTP response with status " + response.statusCode()); } else { ar.cause().printStackTrace(); } }); } }
@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(); } }); } }
@Override public void start() throws Exception { String filename = "upload.txt"; FileSystem fs = vertx.fileSystem(); WebClient client = WebClient.create(vertx); fs.props(filename, ares -> { FileProps props = ares.result(); System.out.println("props is " + props); long size = props.size(); HttpRequest<Buffer> req = client.put(8080, "localhost", "/"); req.putHeader("content-length", "" + size); fs.open(filename, new OpenOptions(), ares2 -> { req.sendStream(ares2.result(), ar -> { if (ar.succeeded()) { HttpResponse<Buffer> response = ar.result(); System.out.println("Got HTTP response with status " + response.statusCode()); } else { ar.cause().printStackTrace(); } }); }); }); } }
@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", "/") .putHeader("content-type", "multipart/form-data") .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(); } }); } }
@Override public void start() throws Exception { // Create the web client and enable SSL/TLS with a trust store WebClient client = WebClient.create(vertx, new WebClientOptions() .setSsl(true) .setTrustStoreOptions(new JksOptions() .setPath("client-truststore.jks") .setPassword("wibble") ) ); client.get(8443, "localhost", "/") .send(ar -> { if (ar.succeeded()) { HttpResponse<Buffer> response = ar.result(); System.out.println("Got HTTP response with status " + response.statusCode()); } else { ar.cause().printStackTrace(); } }); } }
WebClient client = WebClient.create(vertx);
/** * Create a web client using the provided <code>vertx</code> instance and default options. * @param vertx the vertx instance * @return the created web client */ public static io.vertx.rxjava.ext.web.client.WebClient create(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.web.client.WebClient ret = io.vertx.rxjava.ext.web.client.WebClient.newInstance(io.vertx.ext.web.client.WebClient.create(vertx.getDelegate())); return ret; }
/** * Create a web client using the provided <code>vertx</code> instance. * @param vertx the vertx instance * @param options the Web Client options * @return the created web client */ public static io.vertx.rxjava.ext.web.client.WebClient create(io.vertx.rxjava.core.Vertx vertx, WebClientOptions options) { io.vertx.rxjava.ext.web.client.WebClient ret = io.vertx.rxjava.ext.web.client.WebClient.newInstance(io.vertx.ext.web.client.WebClient.create(vertx.getDelegate(), options)); return ret; }
/** * Create a web client using the provided <code>vertx</code> instance and default options. * @param vertx the vertx instance * @return the created web client */ public static io.vertx.rxjava.ext.web.client.WebClient create(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.web.client.WebClient ret = io.vertx.rxjava.ext.web.client.WebClient.newInstance(io.vertx.ext.web.client.WebClient.create(vertx.getDelegate())); return ret; }
/** * Create a web client using the provided <code>vertx</code> instance. * @param vertx the vertx instance * @param options the Web Client options * @return the created web client */ public static io.vertx.rxjava.ext.web.client.WebClient create(io.vertx.rxjava.core.Vertx vertx, WebClientOptions options) { io.vertx.rxjava.ext.web.client.WebClient ret = io.vertx.rxjava.ext.web.client.WebClient.newInstance(io.vertx.ext.web.client.WebClient.create(vertx.getDelegate(), options)); return ret; }
public ConsulClientImpl(Vertx vertx, ConsulClientOptions options) { Objects.requireNonNull(vertx); Objects.requireNonNull(options); webClient = WebClient.create(vertx, options); ctx = vertx.getOrCreateContext(); aclToken = options.getAclToken(); dc = options.getDc(); timeoutMs = options.getTimeout(); }
public static io.vertx.ext.web.client.WebClient create(io.vertx.ext.web.client.WebClient j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> options) { return io.vertx.core.impl.ConversionHelper.fromObject(io.vertx.ext.web.client.WebClient.create(vertx, options != null ? new io.vertx.ext.web.client.WebClientOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(options)) : null)); } public static io.vertx.ext.web.client.WebClient wrap(io.vertx.ext.web.client.WebClient j_receiver, io.vertx.core.http.HttpClient httpClient, java.util.Map<String, Object> options) {
@Override protected void connect() { this.client = WebClient.create(vertx, new WebClientOptions() .setSsl(false) .setTrustAll(true) .setVerifyHost(false)); }
protected void connect() { this.client = WebClient.create(vertx, new WebClientOptions() .setSsl(true) // TODO: Fetch CA and use .setTrustAll(true) .setVerifyHost(false)); }