Java Code Examples for io.vertx.ext.web.client.WebClient#get()

The following examples show how to use io.vertx.ext.web.client.WebClient#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebClientExamples.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
public void multiGet(WebClient client) {
  HttpRequest<Buffer> get = client
    .get(8080, "myserver.mycompany.com", "/some-uri");

  get
    .send()
    .onSuccess(res -> {
      // OK
    });

  // Same request again
  get
    .send()
    .onSuccess(res -> {
      // OK
    });
}
 
Example 2
Source File: WebClientExamples.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
public void multiGetCopy(WebClient client) {
  HttpRequest<Buffer> get = client
    .get(8080, "myserver.mycompany.com", "/some-uri");

  get
    .send()
    .onSuccess(res -> {
      // OK
    });

  // The "get" request instance remains unmodified
  get
    .copy()
    .putHeader("a-header", "with-some-value")
    .send()
    .onSuccess(res -> {
      // OK
    });
}
 
Example 3
Source File: WebClientExamples.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
public void simpleGetWithInitialParams(WebClient client) {
  HttpRequest<Buffer> request = client
    .get(
      8080,
      "myserver.mycompany.com",
      "/some-uri?param1=param1_value&param2=param2_value");

  // Add param3
  request.addQueryParam("param3", "param3_value");

  // Overwrite param2
  request.setQueryParam("param2", "another_param2_value");
}
 
Example 4
Source File: WebClientExamples.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
public void simpleGetOverwritePreviousParams(WebClient client) {
  HttpRequest<Buffer> request = client
    .get(8080, "myserver.mycompany.com", "/some-uri");

  // Add param1
  request.addQueryParam("param1", "param1_value");

  // Overwrite param1 and add param2
  request.uri("/some-uri?param1=param1_value&param2=param2_value");
}
 
Example 5
Source File: WebClientExamples.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
public void sendHeaders1(WebClient client) {
  HttpRequest<Buffer> request = client
    .get(8080, "myserver.mycompany.com", "/some-uri");

  MultiMap headers = request.headers();
  headers.set("content-type", "application/json");
  headers.set("other-header", "foo");
}
 
Example 6
Source File: WebClientExamples.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
public void sendHeaders2(WebClient client) {
  HttpRequest<Buffer> request = client
    .get(8080, "myserver.mycompany.com", "/some-uri");

  request.putHeader("content-type", "application/json");
  request.putHeader("other-header", "foo");
}