本文整理汇总了Java中io.vertx.ext.web.client.WebClient.get方法的典型用法代码示例。如果您正苦于以下问题:Java WebClient.get方法的具体用法?Java WebClient.get怎么用?Java WebClient.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.web.client.WebClient
的用法示例。
在下文中一共展示了WebClient.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
@Test
public void test(TestContext context) throws InterruptedException {
// Async async = context.async();
Vertx vertx = rule.vertx();
WebClient client = WebClient.create(vertx);
HttpRequest<Buffer> req = client.get(41414, "172.21.9.21", "/metrics");
req.putHeader("aa","ccc");
req.timeout(50000);
req.send(ar -> {
if (ar.succeeded()) {
HttpResponse<Buffer> response = ar.result();
System.out.println(response.body());
System.out.println("Received response with status code" + response.statusCode());
} else {
System.out.println("Something went wrong " + ar.cause().getMessage());
}
// async.complete();
});
System.out.println("here1");
// async.awaitSuccess();
}
示例2: simpleGetWithInitialParams
import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
public void simpleGetWithInitialParams(WebClient client) {
HttpRequest<Buffer> request = client.get(8080, "myserver.mycompany.com", "/some-uri?param1=param1_value¶m2=param2_value");
// Add param3
request.addQueryParam("param3", "param3_value");
// Overwrite param2
request.setQueryParam("param2", "another_param2_value");
}
示例3: simpleGetOverwritePreviousParams
import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
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¶m2=param2_value");
}
示例4: multiGet
import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
public void multiGet(WebClient client) {
HttpRequest<Buffer> get = client.get(8080, "myserver.mycompany.com", "/some-uri");
get.send(ar -> {
if (ar.succeeded()) {
// Ok
}
});
// Same request again
get.send(ar -> {
if (ar.succeeded()) {
// Ok
}
});
}
示例5: multiGetCopy
import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
public void multiGetCopy(WebClient client) {
HttpRequest<Buffer> get = client.get(8080, "myserver.mycompany.com", "/some-uri");
get.send(ar -> {
if (ar.succeeded()) {
// Ok
}
});
// The "get" request instance remains unmodified
get.copy().putHeader("a-header", "with-some-value").send(ar -> {
if (ar.succeeded()) {
// Ok
}
});
}
示例6: sendHeaders1
import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
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");
}
示例7: sendHeaders2
import io.vertx.ext.web.client.WebClient; //导入方法依赖的package包/类
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");
}