本文整理了Java中io.vertx.reactivex.ext.web.client.HttpRequest.rxSend()
方法的一些代码示例,展示了HttpRequest.rxSend()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.rxSend()
方法的具体详情如下:
包路径:io.vertx.reactivex.ext.web.client.HttpRequest
类名称:HttpRequest
方法名:rxSend
暂无
代码示例来源: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: io.gravitee.elasticsearch/gravitee-common-elasticsearch
/**
* Get the cluster health
*
* @return the cluster health
* @throws ElasticsearchException error occurs during ES call
*/
@Override
public Single<Health> getClusterHealth() {
return httpClient
.get(URL_STATE_CLUSTER)
.rxSend()
.map(response -> mapper.readValue(response.bodyAsString(), Health.class));
}
代码示例来源:origin: nemtech/nem2-sdk-java
@Override
public Observable<Transaction> getTransaction(String transactionHash) {
return this.client
.getAbs(this.url + transactionHash)
.as(BodyCodec.jsonObject())
.rxSend()
.toObservable()
.map(Http::mapJsonObjectOrError)
.map(json -> new JsonObject(json.toString()))
.map(new TransactionMapping());
}
代码示例来源:origin: nemtech/nem2-sdk-java
public Observable<BigInteger> getBlockchainScore() {
return this.client
.getAbs(this.url + "/chain/score")
.as(BodyCodec.jsonObject())
.rxSend()
.toObservable()
.map(Http::mapJsonObjectOrError)
.map(json -> objectMapper.readValue(json.toString(), BlockchainScoreDTO.class))
.map(blockchainScoreDTO -> blockchainScoreDTO.extractIntArray());
}
代码示例来源:origin: nemtech/nem2-sdk-java
private Observable<List<Transaction>> getBlockTransactions(BigInteger height, Optional<QueryParams> queryParams) {
return this.client
.getAbs(this.url + "/block/" + height + "/transactions" + (queryParams.isPresent() ? queryParams.get().toUrl() : ""))
.as(BodyCodec.jsonArray())
.rxSend()
.toObservable()
.map(Http::mapJsonArrayOrError)
.map(json -> new JsonArray(json.toString()).stream().map(s -> (JsonObject) s).collect(Collectors.toList()))
.flatMapIterable(item -> item)
.map(new TransactionMapping())
.toList()
.toObservable();
}
代码示例来源:origin: nemtech/nem2-sdk-java
@Override
public Observable<BigInteger> getBlockchainHeight() {
return this.client
.getAbs(this.url + "/chain/height")
.as(BodyCodec.jsonObject())
.rxSend()
.toObservable()
.map(Http::mapJsonObjectOrError)
.map(json -> objectMapper.readValue(json.toString(), HeightDTO.class))
.map(blockchainHeight -> blockchainHeight.getHeight().extractIntArray());
}
代码示例来源:origin: nemtech/nem2-sdk-java
private Observable<List<Transaction>> findTransactions(PublicAccount publicAccount, Optional<QueryParams> queryParams, String path) {
return this.client
.getAbs(this.url + publicAccount.getPublicKey() + path + (queryParams.isPresent() ? queryParams.get().toUrl() : ""))
.as(BodyCodec.jsonArray())
.rxSend()
.toObservable()
.map(Http::mapJsonArrayOrError)
.map(json -> new JsonArray(json.toString()).stream().map(s -> (JsonObject) s).collect(Collectors.toList()))
.flatMapIterable(item -> item)
.map(new TransactionMapping())
.toList()
.toObservable();
}
代码示例来源: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: nemtech/nem2-sdk-java
@Override
public Observable<MultisigAccountInfo> getMultisigAccountInfo(Address address) {
Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
return networkTypeResolve
.flatMap(networkType -> this.client
.getAbs(this.url + address.plain() + "/multisig")
.as(BodyCodec.jsonObject())
.rxSend()
.toObservable()
.map(Http::mapJsonObjectOrError)
.map(json -> objectMapper.readValue(json.toString(), MultisigAccountInfoDTO.class))
.map(MultisigAccountInfoDTO::getMultisig)
.map(transfromMultisigAccountInfoDTO(networkType)));
}
代码示例来源:origin: nemtech/nem2-sdk-java
@Override
public Observable<BlockchainStorageInfo> getBlockchainStorage() {
return this.client
.getAbs(this.url + "/diagnostic/storage")
.as(BodyCodec.jsonObject())
.rxSend()
.toObservable()
.map(Http::mapJsonObjectOrError)
.map(json -> objectMapper.readValue(json.toString(), BlockchainStorageInfoDTO.class))
.map(blockchainStorageInfoDTO -> new BlockchainStorageInfo(blockchainStorageInfoDTO.getNumAccounts(),
blockchainStorageInfoDTO.getNumBlocks(),
blockchainStorageInfoDTO.getNumBlocks()));
}
}
代码示例来源:origin: tsegismont/vertx-musicstore
private Single<Buffer> sendGetRequest(String mbAlbumId) {
return webClient
.getAbs("http://coverartarchive.org")
.uri("/release/" + mbAlbumId + "/front")
.as(BodyCodec.buffer())
.rxSend()
.map(HttpResponse::body);
}
代码示例来源:origin: nemtech/nem2-sdk-java
@Override
public Observable<TransactionStatus> getTransactionStatus(String transactionHash) {
return this.client
.getAbs(this.url + transactionHash + "/status")
.as(BodyCodec.jsonObject())
.rxSend()
.toObservable()
.map(Http::mapJsonObjectOrError)
.map(json -> objectMapper.readValue(json.toString(), TransactionStatusDTO.class))
.map(transactionStatusDTO -> new TransactionStatus(transactionStatusDTO.getGroup(),
transactionStatusDTO.getStatus(),
transactionStatusDTO.getHash(),
new Deadline(transactionStatusDTO.getDeadline().extractIntArray()),
transactionStatusDTO.getHeight().extractIntArray()));
}
代码示例来源:origin: io.gravitee.am.identityprovider/gravitee-am-identityprovider-oauth2-generic
private Maybe<User> profile(String accessToken) {
return client.getAbs(configuration.getUserProfileUri())
.putHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)
.rxSend()
.toMaybe()
.map(httpClientResponse -> {
if (httpClientResponse.statusCode() != 200) {
throw new BadCredentialsException(httpClientResponse.statusMessage());
}
return createUser(httpClientResponse.bodyAsJsonObject());
});
}
代码示例来源:origin: io.gravitee.am.identityprovider/gravitee-am-identityprovider-github
private Maybe<User> profile(String accessToken) {
return client.getAbs(configuration.getUserProfileUri())
.putHeader(HttpHeaders.AUTHORIZATION, "token " + accessToken)
.rxSend()
.toMaybe()
.map(httpClientResponse -> {
if (httpClientResponse.statusCode() != 200) {
throw new BadCredentialsException(httpClientResponse.statusMessage());
}
return createUser(httpClientResponse.bodyAsJsonObject());
});
}
代码示例来源:origin: gravitee-io/graviteeio-access-management
private Maybe<User> profile(String accessToken) {
return client.getAbs(configuration.getUserProfileUri())
.putHeader(HttpHeaders.AUTHORIZATION, "token " + accessToken)
.rxSend()
.toMaybe()
.map(httpClientResponse -> {
if (httpClientResponse.statusCode() != 200) {
throw new BadCredentialsException(httpClientResponse.statusMessage());
}
return createUser(httpClientResponse.bodyAsJsonObject());
});
}
代码示例来源:origin: gravitee-io/graviteeio-access-management
private Maybe<User> profile(String accessToken) {
return client.getAbs(configuration.getUserProfileUri())
.putHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)
.rxSend()
.toMaybe()
.map(httpClientResponse -> {
if (httpClientResponse.statusCode() != 200) {
throw new BadCredentialsException(httpClientResponse.statusMessage());
}
return createUser(httpClientResponse.bodyAsJsonObject());
});
}
代码示例来源: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));
});
}
内容来源于网络,如有侵权,请联系作者删除!