當前位置: 首頁>>代碼示例>>Java>>正文


Java Vertx.createHttpClient方法代碼示例

本文整理匯總了Java中io.vertx.core.Vertx.createHttpClient方法的典型用法代碼示例。如果您正苦於以下問題:Java Vertx.createHttpClient方法的具體用法?Java Vertx.createHttpClient怎麽用?Java Vertx.createHttpClient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.vertx.core.Vertx的用法示例。


在下文中一共展示了Vertx.createHttpClient方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hello3

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Path("3")
@GET
public void hello3(@Suspended final AsyncResponse asyncResponse,
	      // Inject the Vertx instance
	      @Context Vertx vertx){
	System.err.println("Creating client");
	HttpClientOptions options = new HttpClientOptions();
	options.setSsl(true);
	options.setTrustAll(true);
	options.setVerifyHost(false);
	HttpClient client = vertx.createHttpClient(options);
	client.getNow(443,
			"www.google.com", 
			"/robots.txt", 
			resp -> {
				System.err.println("Got response");
				resp.bodyHandler(body -> {
					System.err.println("Got body");
					asyncResponse.resume(Response.ok(body.toString()).build());
				});
			});
	System.err.println("Created client");
}
 
開發者ID:FroMage,項目名稱:redpipe,代碼行數:24,代碼來源:MyResource.java

示例2: createClientPool

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Test
public void createClientPool(@Mocked Vertx vertx, @Mocked Context context, @Mocked HttpClient httpClient) {
  new Expectations(VertxImpl.class) {
    {
      VertxImpl.context();
      result = context;
      context.owner();
      result = vertx;
      vertx.createHttpClient(httpClientOptions);
      result = httpClient;
    }
  };
  HttpClientWithContext pool = factory.createClientPool();

  Assert.assertSame(context, pool.context());
  Assert.assertSame(httpClient, pool.getHttpClient());
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:18,代碼來源:TestHttpClientPoolFactory.java

示例3: init

import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static void init(){
    Vertx vertx = Constants.vertx();
    if(vertx == null){
        throw new RuntimeException("請先初始化Constants類!");
    }
    client = vertx.createHttpClient(new HttpClientOptions().setLogActivity(false));
}
 
開發者ID:Leibnizhu,項目名稱:AlipayWechatPlatform,代碼行數:8,代碼來源:NetworkUtils.java

示例4: HttpClientTest

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Test
public void HttpClientTest() {
    Vertx vertx = Vertx.vertx();
    System.out.println("===================Test start===================");
    HttpClient client = vertx.createHttpClient();
    client.get(8080, "localhost", "/api/prod/dfsad", response -> {
        System.out.println("Received response with status code " + response.statusCode());
    }).end();
}
 
開發者ID:Leibnizhu,項目名稱:AlipayWechatPlatform,代碼行數:10,代碼來源:NetworkUtilTest.java

示例5: hello4

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Path("4")
@GET
public void hello4(@Suspended final AsyncResponse asyncResponse,
	      // Inject the Vertx instance
	      @Context Vertx vertx){
	System.err.println("Creating client");
	HttpClientOptions options = new HttpClientOptions();
	options.setSsl(true);
	options.setTrustAll(true);
	options.setVerifyHost(false);
	HttpClient client = vertx.createHttpClient(options);
	ObservableHandler<HttpClientResponse> responseHandler = RxHelper.observableHandler();
	client.getNow(443,
			"www.google.com", 
			"/robots.txt", 
			responseHandler.toHandler());
	
	ObservableHandler<Buffer> bodyHandler = RxHelper.observableHandler();
	responseHandler.subscribe(resp -> {
		System.err.println("Got response");
		resp.bodyHandler(bodyHandler.toHandler());
	});
	
	bodyHandler.subscribe(body -> {
		System.err.println("Got body");
		asyncResponse.resume(Response.ok(body.toString()).build());
	});
	System.err.println("Created client");
}
 
開發者ID:FroMage,項目名稱:redpipe,代碼行數:30,代碼來源:MyResource.java

示例6: create

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Override
public ConfigStore create(Vertx vertx, JsonObject configuration) {
  String host = configuration.getString("host");
  int port = configuration.getInteger("port", 80);
  String path = configuration.getString("path", "/");
  String username = configuration.getString("username", "");
  String password = configuration.getString("password", "");
  HttpClient client = vertx.createHttpClient(new HttpClientOptions()
      .setSsl(configuration.getBoolean("ssl", false))
      .setDefaultHost(host)
      .setDefaultPort(port)
      .setTrustAll(true));
  return new HttpBasicAuthConfigStore(client, path, username, password);
}
 
開發者ID:kristenkotkas,項目名稱:moviediary,代碼行數:15,代碼來源:HttpBasicAuthConfigStoreFactory.java

示例7: NexusHttpProxy

import io.vertx.core.Vertx; //導入方法依賴的package包/類
private NexusHttpProxy(final Vertx vertx,
                       final String host,
                       final int port,
                       final String nexusRutHeader) {
    this.host = host;
    this.httpClient = vertx.createHttpClient();
    this.nexusRutHeader = nexusRutHeader;
    this.port = port;
}
 
開發者ID:travelaudience,項目名稱:nexus-proxy,代碼行數:10,代碼來源:NexusHttpProxy.java

示例8: init

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Override
public void init(Vertx vertx, Context context) {
    super.init(vertx, context);

    httpClient = vertx.createHttpClient();

}
 
開發者ID:benemon,項目名稱:he-rss-poll,代碼行數:8,代碼來源:PollingVerticle.java

示例9: HttpClient

import io.vertx.core.Vertx; //導入方法依賴的package包/類
public HttpClient(Vertx vertx) {
  client = vertx.createHttpClient();
}
 
開發者ID:folio-org,項目名稱:mod-circulation-storage,代碼行數:4,代碼來源:HttpClient.java

示例10: httpClient

import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Bean
public HttpClient httpClient(final Vertx vertx,
    final HttpClientOptions httpClientOptions) {

    return vertx.createHttpClient(httpClientOptions);
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:7,代碼來源:VertxBeanProvider.java


注:本文中的io.vertx.core.Vertx.createHttpClient方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。