use of io.vertx.core.http.HttpClientRequest in project mod-inventory-storage by folio-org.
the class MaterialTypeTest method send.
private void send(String url, HttpMethod method, String content, String contentType, Handler<HttpClientResponse> handler) {
HttpClient client = StorageTestSuite.getVertx().createHttpClient();
HttpClientRequest request;
if (content == null) {
content = "";
}
Buffer buffer = Buffer.buffer(content);
if (method == HttpMethod.POST) {
request = client.postAbs(url);
} else if (method == HttpMethod.DELETE) {
request = client.deleteAbs(url);
} else if (method == HttpMethod.GET) {
request = client.getAbs(url);
} else {
request = client.putAbs(url);
}
request.exceptionHandler(error -> {
Assert.fail(error.getLocalizedMessage());
}).handler(handler);
request.putHeader("Authorization", "test_tenant");
request.putHeader("x-okapi-tenant", "test_tenant");
request.putHeader("Accept", "application/json,text/plain");
request.putHeader("Content-type", contentType);
request.end(buffer);
}
use of io.vertx.core.http.HttpClientRequest in project mod-inventory-storage by folio-org.
the class HttpClient method post.
public void post(URL url, Object body, String tenantId, Handler<HttpClientResponse> responseHandler) {
HttpClientRequest request = client.postAbs(url.toString(), responseHandler);
request.headers().add("Accept", "application/json, text/plain");
request.headers().add("Content-type", "application/json");
if (tenantId != null) {
request.headers().add(TENANT_HEADER, tenantId);
}
if (body == null) {
request.end();
return;
}
String encodedBody = Json.encodePrettily(body);
log.debug("POST {0}, Request: {1}", url.toString(), encodedBody);
request.end(encodedBody);
}
use of io.vertx.core.http.HttpClientRequest in project mod-inventory-storage by folio-org.
the class HttpClient method delete.
public void delete(String url, String tenantId, Handler<HttpClientResponse> responseHandler) {
HttpClientRequest request = client.deleteAbs(url, responseHandler);
request.headers().add("Accept", "application/json, text/plain");
if (tenantId != null) {
request.headers().add(TENANT_HEADER, tenantId);
}
request.end();
}
use of io.vertx.core.http.HttpClientRequest in project mod-inventory-storage by folio-org.
the class HttpClient method put.
public void put(URL url, Object body, String tenantId, Handler<HttpClientResponse> responseHandler) {
HttpClientRequest request = client.putAbs(url.toString(), responseHandler);
request.headers().add("Accept", "application/json, text/plain");
request.headers().add("Content-type", "application/json");
if (tenantId != null) {
request.headers().add(TENANT_HEADER, tenantId);
}
request.end(Json.encodePrettily(body));
}
use of io.vertx.core.http.HttpClientRequest in project mod-inventory-storage by folio-org.
the class HttpClient method get.
public void get(String url, String tenantId, Handler<HttpClientResponse> responseHandler) {
HttpClientRequest request = client.getAbs(url, responseHandler);
request.headers().add("Accept", "application/json");
if (tenantId != null) {
request.headers().add(TENANT_HEADER, tenantId);
}
request.end();
}
Aggregations