io.vertx.ext.web.client.WebClient.create()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中io.vertx.ext.web.client.WebClient.create()方法的一些代码示例,展示了WebClient.create()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.create()方法的具体详情如下:
包路径:io.vertx.ext.web.client.WebClient
类名称:WebClient
方法名:create

WebClient.create介绍

暂无

代码示例

代码示例来源:origin: vert-x3/vertx-examples

@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();
   }
  });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

@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();
   }
  });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

@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();
   }
  });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

@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();
    }
   });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

@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();
   }
  });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

@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();
    }
   });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

@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();
    }
   });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

@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();
   }
  });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

@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();
     }
    });
   });
  });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

@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();
    }
   });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

@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();
    }
   });
 }
}

代码示例来源:origin: vert-x3/vertx-examples

WebClient client = WebClient.create(vertx);

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * 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;
}

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * 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;
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * 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;
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * 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;
}

代码示例来源:origin: io.vertx/vertx-consul-client

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();
}

代码示例来源:origin: io.vertx/vertx-lang-groovy

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) {

代码示例来源:origin: EnMasseProject/enmasse

@Override
protected void connect() {
  this.client = WebClient.create(vertx, new WebClientOptions()
      .setSsl(false)
      .setTrustAll(true)
      .setVerifyHost(false));
}

代码示例来源:origin: EnMasseProject/enmasse

protected void connect() {
  this.client = WebClient.create(vertx, new WebClientOptions()
      .setSsl(true)
      // TODO: Fetch CA and use
      .setTrustAll(true)
      .setVerifyHost(false));
}

相关文章