use of io.vertx.ext.web.client.HttpRequest in project raml-module-builder by folio-org.
the class DemoRamlRestTest method checkURLs.
public static Buffer checkURLs(TestContext context, String tenant, String url, int codeExpected, String accept) {
Buffer res = Buffer.buffer();
try {
Async async = context.async();
WebClient client = WebClient.create(vertx);
final HttpRequest<Buffer> request = client.getAbs(url);
if (tenant != null) {
request.headers().add("x-okapi-tenant", tenant);
}
if (accept != null) {
request.headers().add("Accept", accept);
}
request.send(x -> {
x.map(httpClientResponse -> {
res.appendBuffer(httpClientResponse.body());
log.info(httpClientResponse.statusCode() + ", " + codeExpected + " status expected: " + url);
log.info(res);
context.assertEquals(codeExpected, httpClientResponse.statusCode(), url);
async.complete();
return null;
}).otherwise(f -> {
context.fail(url + " - " + f.getMessage());
async.complete();
return null;
});
});
async.await();
} catch (Throwable e) {
log.error(e.getMessage(), e);
context.fail(e);
}
return res;
}
use of io.vertx.ext.web.client.HttpRequest in project vertx-web by vert-x3.
the class ApiClient method querySpaceDelimitedNoexplodeArray.
/**
* Call query_spaceDelimited_noexplode_array with empty body.
* @param color Parameter color inside query
* @param handler The handler for the asynchronous request
*/
public void querySpaceDelimitedNoexplodeArray(List<Object> color, Handler<AsyncResult<HttpResponse>> handler) {
// Check required params
if (color == null)
throw new RuntimeException("Missing parameter color");
// Generate the uri
String uri = "/query/spaceDelimited/noexplode/array";
HttpRequest request = client.get(uri);
MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
if (color != null)
this.addQueryArraySpaceDelimited("color", color, request);
this.renderAndAttachCookieHeader(request, requestCookies);
request.send(handler);
}
use of io.vertx.ext.web.client.HttpRequest in project vertx-web by vert-x3.
the class ApiClient method queryDeepObjectExplodeObject.
/**
* Call query_deepObject_explode_object with empty body.
* @param color Parameter color inside query
* @param handler The handler for the asynchronous request
*/
public void queryDeepObjectExplodeObject(Map<String, Object> color, Handler<AsyncResult<HttpResponse>> handler) {
// Check required params
if (color == null)
throw new RuntimeException("Missing parameter color");
// Generate the uri
String uri = "/query/deepObject/explode/object";
HttpRequest request = client.get(uri);
MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
if (color != null)
this.addQueryObjectDeepObjectExplode("color", color, request);
this.renderAndAttachCookieHeader(request, requestCookies);
request.send(handler);
}
use of io.vertx.ext.web.client.HttpRequest in project vertx-web by vert-x3.
the class ApiClient method queryFormExplodeEmpty.
/**
* Call query_form_explode_empty with empty body.
* @param color Parameter color inside query
* @param handler The handler for the asynchronous request
*/
public void queryFormExplodeEmpty(String color, Handler<AsyncResult<HttpResponse>> handler) {
// Check required params
if (color == null)
throw new RuntimeException("Missing parameter color");
// Generate the uri
String uri = "/query/form/explode/empty";
HttpRequest request = client.get(uri);
MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
if (color != null)
this.addQueryParam("color", color, request);
this.renderAndAttachCookieHeader(request, requestCookies);
request.send(handler);
}
use of io.vertx.ext.web.client.HttpRequest in project vertx-web by vert-x3.
the class ApiClient method pathMatrixExplodeString.
/**
* Call path_matrix_explode_string with empty body.
* @param color Parameter color inside path
* @param handler The handler for the asynchronous request
*/
public void pathMatrixExplodeString(String color, Handler<AsyncResult<HttpResponse>> handler) {
// Check required params
if (color == null)
throw new RuntimeException("Missing parameter color in path");
// Generate the uri
String uri = "/path/matrix/explode/string/{;color*}";
// Remove * . ; ? from url template
uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}");
uri = uri.replace("{color}", this.renderPathMatrix("color", color));
HttpRequest request = client.get(uri);
MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
this.renderAndAttachCookieHeader(request, requestCookies);
request.send(handler);
}
Aggregations