本文整理了Java中io.vertx.reactivex.ext.web.client.WebClient.create()
方法的一些代码示例,展示了WebClient.create()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.create()
方法的具体详情如下:
包路径:io.vertx.reactivex.ext.web.client.WebClient
类名称:WebClient
方法名:create
暂无
代码示例来源:origin: vert-x3/vertx-examples
@Override
public void start() throws Exception {
WebClient client = WebClient.create(vertx);
client.get(80, "perdu.com", "/")
.rxSend()
.map(HttpResponse::bodyAsString)
.subscribe(
s -> LOGGER.info("From web client: " + s),
Throwable::printStackTrace
);
}
}
代码示例来源:origin: vert-x3/vertx-examples
@Override
public void start() throws Exception {
WebClient client = WebClient.create(vertx);
Single<HttpResponse<String>> request = client.get(8080, "localhost", "/")
.as(BodyCodec.string())
.rxSend();
// Fire the request
request.subscribe(resp -> System.out.println("Server content " + resp.body()));
// Again
request.subscribe(resp -> System.out.println("Server content " + resp.body()));
// And again
request.subscribe(resp -> System.out.println("Server content " + resp.body()));
}
}
代码示例来源:origin: vert-x3/vertx-examples
@Override
public void start() throws Exception {
WebClient client = WebClient.create(vertx);
Single<HttpResponse<Data>> request = client.get(8080, "localhost", "/")
.as(BodyCodec.json(Data.class))
.rxSend();
// Fire the request
request.subscribe(resp -> System.out.println("Server content " + resp.body().message));
// Again
request.subscribe(resp -> System.out.println("Server content " + resp.body().message));
// And again
request.subscribe(resp -> System.out.println("Server content " + resp.body().message));
}
}
代码示例来源:origin: vert-x3/vertx-examples
@Override
public void start() throws Exception {
// Create two requests
WebClient client = WebClient.create(vertx);
Single<JsonObject> request = client.get(8080, "localhost", "/")
.as(BodyCodec.jsonObject())
.rxSend()
.map(resp -> resp.body());
// Combine the responses with the zip into a single response
request
.zipWith(request, (b1, b2) -> new JsonObject().put("req1", b1).put("req2", b2))
.subscribe(json -> {
System.out.println("Got combined result " + json);
}, err -> {
err.printStackTrace();
});
}
}
代码示例来源:origin: nemtech/nem2-sdk-java
Http(String host, NetworkHttp networkHttp) throws MalformedURLException {
this.url = new URL(host);
final Vertx vertx = Vertx.vertx();
this.client = WebClient.create(vertx);
objectMapper.configure(DeserializationFeature.USE_LONG_FOR_INTS, true);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.networkHttp = networkHttp;
}
代码示例来源:origin: io.knotx/knotx-example-action-adapter-http
private WebClient getWebClient(Vertx vertx, HttpAdapterConfiguration configuration) {
JsonObject clientOptions = configuration.getClientOptions();
return clientOptions.isEmpty() ? WebClient.create(vertx) :
WebClient.create(vertx, new WebClientOptions(clientOptions));
}
代码示例来源:origin: gravitee-io/graviteeio-access-management
@Bean
public WebClient webClient() {
WebClientOptions options = new WebClientOptions()
.setConnectTimeout(Integer.valueOf(properties.getProperty("oidc.http.connectionTimeout", DEFAULT_CONNECTION_TIMEOUT)) * 1000)
.setMaxPoolSize(Integer.valueOf(properties.getProperty("oidc.http.pool.maxTotalConnection", DEFAULT_MAX_TOTAL_CONNECTION)))
.setTrustAll(Boolean.valueOf(properties.getProperty("oidc.http.client.trustAll", "true")));
return WebClient.create(vertx,options);
}
}
代码示例来源:origin: gravitee-io/graviteeio-access-management
@Bean
public WebClient httpClient() {
WebClientOptions httpClientOptions = new WebClientOptions();
httpClientOptions
.setUserAgent(DEFAULT_USER_AGENT)
.setConnectTimeout(Integer.valueOf(properties.getProperty("identities.oauth2.http.connectionTimeout", DEFAULT_CONNECTION_TIMEOUT)) * 1000)
.setMaxPoolSize(Integer.valueOf(properties.getProperty("identities.oauth2.http.pool.maxTotalConnection", DEFAULT_MAX_TOTAL_CONNECTION)));
return WebClient.create(vertx, httpClientOptions);
}
}
代码示例来源:origin: io.gravitee.am.identityprovider/gravitee-am-identityprovider-oauth2-generic
@Bean
public WebClient httpClient() {
WebClientOptions httpClientOptions = new WebClientOptions();
httpClientOptions
.setUserAgent(DEFAULT_USER_AGENT)
.setConnectTimeout(Integer.valueOf(properties.getProperty("identities.oauth2.http.connectionTimeout", DEFAULT_CONNECTION_TIMEOUT)) * 1000)
.setMaxPoolSize(Integer.valueOf(properties.getProperty("identities.oauth2.http.pool.maxTotalConnection", DEFAULT_MAX_TOTAL_CONNECTION)));
return WebClient.create(vertx, httpClientOptions);
}
}
代码示例来源:origin: io.gravitee.am.identityprovider/gravitee-am-identityprovider-github
@Bean
public WebClient httpClient() {
WebClientOptions httpClientOptions = new WebClientOptions();
httpClientOptions
.setUserAgent(DEFAULT_USER_AGENT)
.setConnectTimeout(Integer.valueOf(properties.getProperty("identities.github.http.connectionTimeout", DEFAULT_CONNECTION_TIMEOUT)) * 1000)
.setMaxPoolSize(Integer.valueOf(properties.getProperty("identities.github.http.pool.maxTotalConnection", DEFAULT_MAX_TOTAL_CONNECTION)));
return WebClient.create(vertx, httpClientOptions);
}
}
代码示例来源:origin: io.knotx.acme/acme-action-adapter-http
public HttpActionAdapterProxyImpl(Vertx vertx, ServiceAdapterOptions configuration) {
this.httpClientFacade = new HttpClientFacade(
WebClient.create(vertx, configuration.getClientOptions()),
configuration);
}
代码示例来源:origin: io.knotx.acme/acme-forms-adapter-http
public FormsAdapterProxyImpl(Vertx vertx, HttpFormsAdapterOptions configuration) {
this.httpClientFacade = new HttpClientFacade(
WebClient.create(vertx, configuration.getClientOptions()),
configuration);
}
代码示例来源:origin: gravitee-io/graviteeio-access-management
@Bean
public WebClient httpClient() {
WebClientOptions httpClientOptions = new WebClientOptions();
httpClientOptions
.setUserAgent(DEFAULT_USER_AGENT)
.setConnectTimeout(Integer.valueOf(properties.getProperty("identities.github.http.connectionTimeout", DEFAULT_CONNECTION_TIMEOUT)) * 1000)
.setMaxPoolSize(Integer.valueOf(properties.getProperty("identities.github.http.pool.maxTotalConnection", DEFAULT_MAX_TOTAL_CONNECTION)));
return WebClient.create(vertx, httpClientOptions);
}
}
代码示例来源:origin: io.knotx/knotx-adapter-service-http
public HttpServiceAdapterProxyImpl(Vertx vertx, ServiceAdapterOptions configuration) {
this.httpClientFacade = new HttpClientFacade(
WebClient.create(vertx, configuration.getClientOptions()), configuration);
}
代码示例来源:origin: io.knotx/knotx-databridge-adapter-http
public HttpDataSourceAdapterProxy(Vertx vertx, HttpDataSourceAdapterOptions configuration) {
this.httpClientFacade = new HttpClientFacade(
WebClient.create(vertx, configuration.getClientOptions()), configuration);
}
代码示例来源:origin: Cognifide/knotx
public HttpServiceAdapterProxyImpl(Vertx vertx, ServiceAdapterOptions configuration) {
this.httpClientFacade = new HttpClientFacade(
WebClient.create(vertx, configuration.getClientOptions()), configuration);
}
代码示例来源:origin: FroMage/redpipe
private Single<String> get(Vertx vertx, URI uri){
WebClient client = WebClient.create(vertx);
Single<HttpResponse<Buffer>> responseHandler =
client.get(uri.getPort(), uri.getHost(), uri.getPath()).rxSend();
return responseHandler.map(response -> response.body().toString())
.doAfterTerminate(() -> client.close());
}
代码示例来源:origin: Cognifide/knotx
private void testPostRequest(VertxTestContext context, Vertx vertx, String url,
Consumer<HttpResponse<Buffer>> expectedResponse) {
WebClient client = WebClient.create(vertx);
MultiMap formData = MultiMap.caseInsensitiveMultiMap();
formData.add("a", "b");
Single<HttpResponse<Buffer>> httpResponseSingle = client
.post(KnotxServerRoutingTest.KNOTX_SERVER_PORT,
KnotxServerRoutingTest.KNOTX_SERVER_ADDRESS,
url)
.rxSendForm(formData);
subscribeToResult_shouldSucceed(context, httpResponseSingle, expectedResponse);
}
代码示例来源:origin: Cognifide/knotx
private void testGetRequest(VertxTestContext context, Vertx vertx, String url,
String expectedResult) {
WebClient client = WebClient.create(vertx);
Single<HttpResponse<Buffer>> httpResponseSingle = client
.get(KNOTX_SERVER_PORT, KNOTX_SERVER_ADDRESS, url).rxSend();
subscribeToResult_shouldSucceed(context, httpResponseSingle,
resp -> {
assertEquals(expectedResult, resp.body().toString(),
"Wrong engines processed request, expected " + expectedResult);
assertEquals(HttpResponseStatus.OK.code(), resp.statusCode());
assertNotNull(resp.getHeader(EXPECTED_RESPONSE_HEADER));
assertEquals(EXPECTED_XSERVER_HEADER_VALUE,
resp.getHeader(EXPECTED_RESPONSE_HEADER));
});
}
代码示例来源:origin: Cognifide/knotx
@Test
@KnotxApplyConfiguration("io/knotx/server/test-server-csrf.json")
public void whenDoPostPublicWithoutCSRF_expectOk(
VertxTestContext context, Vertx vertx) {
createPassThroughKnot(vertx, "test-splitter");
createPassThroughKnot(vertx, "test-assembler");
createSimpleKnot(vertx, "some-knot", "test", null);
MultiMap body = MultiMap.caseInsensitiveMultiMap().add("field", "value");
WebClient client = WebClient.create(vertx);
Single<HttpResponse<io.vertx.reactivex.core.buffer.Buffer>> httpResponseSingle = client
.post(KNOTX_SERVER_PORT, KNOTX_SERVER_ADDRESS, "/content/local/public.html")
.rxSendForm(body);
subscribeToResult_shouldSucceed(context, httpResponseSingle, resp -> {
assertEquals(HttpResponseStatus.OK.code(), resp.statusCode());
});
}
内容来源于网络,如有侵权,请联系作者删除!