Java Code Examples for io.vertx.ext.web.client.HttpRequest#send()

The following examples show how to use io.vertx.ext.web.client.HttpRequest#send() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call header_simple_noexplode_object with empty body.
 * @param color Parameter color inside header
 * @param handler The handler for the asynchronous request
 */
public void headerSimpleNoexplodeObject(
    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 = "/header/simple/noexplode/object";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addHeaderObjectSimple("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 2
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call query_form_explode_string with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormExplodeString(
    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/string";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addQueryParam("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 3
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call query_form_noexplode_string with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormNoexplodeString(
    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/noexplode/string";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addQueryParam("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 4
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call path_multi_simple_matrix with empty body.
 * @param colorSimple Parameter color_simple inside path
 * @param colorMatrix Parameter color_matrix inside path
 * @param handler The handler for the asynchronous request
 */
public void pathMultiSimpleMatrix(
    String colorSimple,
    List<Object> colorMatrix,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (colorSimple == null) throw new RuntimeException("Missing parameter colorSimple in path");
    if (colorMatrix == null) throw new RuntimeException("Missing parameter colorMatrix in path");


    // Generate the uri
    String uri = "/path/multi/{color_simple}{;color_matrix}/test";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color_simple}", this.renderPathParam("color_simple", colorSimple));
    uri = uri.replace("{color_matrix}", this.renderPathArrayMatrix("color_matrix", colorMatrix));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 5
Source File: ApiClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call query_form_explode_object with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormExplodeObject(
    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/form/explode/object";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addQueryObjectFormExplode("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 6
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call header_simple_noexplode_array with empty body.
 * @param color Parameter color inside header
 * @param handler The handler for the asynchronous request
 */
public void headerSimpleNoexplodeArray(
    List<Object> color,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (color == null) throw new RuntimeException("Missing parameter color");


    // Generate the uri
    String uri = "/header/simple/noexplode/array";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addHeaderArraySimple("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 7
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call cookie_form_noexplode_object with empty body.
 * @param color Parameter color inside cookie
 * @param handler The handler for the asynchronous request
 */
public void cookieFormNoexplodeObject(
    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 = "/cookie/form/noexplode/object";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.renderCookieObjectForm("color", color, requestCookies);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 8
Source File: ApiClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call query_form_noexplode_string with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormNoexplodeString(
    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/noexplode/string";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addQueryParam("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 9
Source File: ApiClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call cookie_form_noexplode_object with empty body.
 * @param color Parameter color inside cookie
 * @param handler The handler for the asynchronous request
 */
public void cookieFormNoexplodeObject(
    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 = "/cookie/form/noexplode/object";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.renderCookieObjectForm("color", color, requestCookies);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 10
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call query_form_noexplode_empty with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormNoexplodeEmpty(
    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/noexplode/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);
}
 
Example 11
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call cookie_form_explode_empty with empty body.
 * @param color Parameter color inside cookie
 * @param handler The handler for the asynchronous request
 */
public void cookieFormExplodeEmpty(
    String color,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (color == null) throw new RuntimeException("Missing parameter color");


    // Generate the uri
    String uri = "/cookie/form/explode/empty";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.renderCookieParam("color", color, requestCookies);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 12
Source File: ApiClient.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
/**
 * Call query_form_noexplode_empty with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormNoexplodeEmpty(
    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/noexplode/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);
}
 
Example 13
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
/**
 * Call path_label_noexplode_string with empty body.
 * @param color Parameter color inside path
 * @param handler The handler for the asynchronous request
 */
public void pathLabelNoexplodeString(
    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/label/noexplode/string/{.color}";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color}", this.renderPathLabel("color", color));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 14
Source File: ApiClient.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
/**
 * Invoke API by sending HTTP request with the given options.
 *
 * @param <T> Type
 * @param path The sub-path of the HTTP URL
 * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"
 * @param queryParams The query parameters
 * @param body The request body object
 * @param headerParams The header parameters
 * @param cookieParams The cookie parameters
 * @param formParams The form parameters
 * @param accepts The request's Accept headers
 * @param contentTypes The request's Content-Type headers
 * @param authNames The authentications to apply
 * @param returnType The return type into which to deserialize the response
 * @param resultHandler The asynchronous response handler
 */
public <T> void invokeAPI(String path, String method, List<Pair> queryParams, Object body, MultiMap headerParams,
                          MultiMap cookieParams, Map<String, Object> formParams, String[] accepts, String[] contentTypes, String[] authNames,
                          TypeReference<T> returnType, Handler<AsyncResult<T>> resultHandler) {

    updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);

    if (accepts != null && accepts.length > 0) {
        headerParams.add(HttpHeaders.ACCEPT, selectHeaderAccept(accepts));
    }

    if (contentTypes != null) {
        headerParams.add(HttpHeaders.CONTENT_TYPE, selectHeaderContentType(contentTypes));
    }

    HttpMethod httpMethod = HttpMethod.valueOf(method);
    HttpRequest<Buffer> request = getWebClient().requestAbs(httpMethod, basePath + path);

    if (httpMethod == HttpMethod.PATCH) {
        request.putHeader("X-HTTP-Method-Override", "PATCH");
    }

    queryParams.forEach(entry -> {
        if (entry.getValue() != null) {
            request.addQueryParam(entry.getName(), entry.getValue());
        }
    });

    headerParams.forEach(entry -> {
        if (entry.getValue() != null) {
            request.putHeader(entry.getKey(), entry.getValue());
        }
    });

    defaultHeaders.forEach(entry -> {
        if (entry.getValue() != null) {
            request.putHeader(entry.getKey(), entry.getValue());
        }
    });

    final MultiMap cookies = MultiMap.caseInsensitiveMultiMap().addAll(cookieParams).addAll(defaultCookies);
    request.putHeader("Cookie", buildCookieHeader(cookies));

    Handler<AsyncResult<HttpResponse<Buffer>>> responseHandler = buildResponseHandler(returnType, resultHandler);
    if (body != null) {
        sendBody(request, responseHandler, body);
    } else if (formParams != null && !formParams.isEmpty()) {
        Map<String, String> formMap = formParams.entrySet().stream().collect(toMap(Map.Entry::getKey, entry -> parameterToString(entry.getValue())));
        MultiMap form = MultiMap.caseInsensitiveMultiMap().addAll(formMap);
        request.sendForm(form, responseHandler);
    } else {
        request.send(responseHandler);
    }
}
 
Example 15
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
/**
 * 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*}";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color}", this.renderPathMatrix("color", color));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 16
Source File: ApiClient.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
/**
 * Call path_label_noexplode_array with empty body.
 * @param color Parameter color inside path
 * @param handler The handler for the asynchronous request
 */
public void pathLabelNoexplodeArray(
    List<Object> 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/label/noexplode/array/{.color}";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color}", this.renderPathArrayLabel("color", color));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 17
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
/**
 * Call path_simple_noexplode_array with empty body.
 * @param color Parameter color inside path
 * @param handler The handler for the asynchronous request
 */
public void pathSimpleNoexplodeArray(
    List<Object> 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/simple/noexplode/array/{color}";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color}", this.renderPathArraySimple("color", color));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 18
Source File: ApiClient.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
/**
 * Call path_simple_explode_array with empty body.
 * @param color Parameter color inside path
 * @param handler The handler for the asynchronous request
 */
public void pathSimpleExplodeArray(
    List<Object> 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/simple/explode/array/{color*}";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color}", this.renderPathArraySimpleExplode("color", color));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 19
Source File: ParametersTestAPIClient.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
/**
 * Call path_simple_explode_array with empty body.
 * @param color Parameter color inside path
 * @param handler The handler for the asynchronous request
 */
public void pathSimpleExplodeArray(
    List<Object> 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/simple/explode/array/{color*}";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color}", this.renderPathArraySimpleExplode("color", color));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
Example 20
Source File: ApiClient.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
/**
 * Call path_simple_noexplode_object with empty body.
 * @param color Parameter color inside path
 * @param handler The handler for the asynchronous request
 */
public void pathSimpleNoexplodeObject(
    Map<String, Object> 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/simple/noexplode/object/{color}";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color}", this.renderPathObjectSimple("color", color));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}