All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.get.Java.handlebars Maven / Gradle / Ivy

The newest version!
HttpClient client = HttpClient.newHttpClient();
{{#if item}}
String {{item.name}} = "{{item.value}}";

{{/if}}
HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create(baseUrl{{#each chunks}} + {{#unless this.param}}"{{/unless}}{{this.path}}{{#unless this.param}}"{{/unless}}{{/each}}))
        .setHeader("Accept", "application/json")
        .setHeader("Authorization", "Bearer " + authToken)
        .build();

HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == HttpURLConnection.HTTP_OK) {
    {{type}}{{#if array}}[]{{/if}} {{name}} = new Gson().fromJson(response.body(), {{type}}{{#if array}}[]{{/if}}.class);
{{#if item}}
    assert {{name}}.get{{capitalize item.name}}().equals({{item.name}});
{{/if}}
    System.out.println("{{name}}: " + response.body());
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy