private String get(final Function<UriBuilder, URI> builder, final HttpStatus status) { return new String(client.get() .uri(builder) .accept(TEXT_HTML).exchange() .expectStatus().isEqualTo(status) .expectHeader().contentType(TEXT_HTML) .expectBody().returnResult().getResponseBody()); }
protected <T> T get(final Function<UriBuilder, URI> builder, final HttpStatus status, final Class<T> type) { return client.get() .uri(builder) .accept(APPLICATION_JSON_UTF8).exchange() .expectStatus().isEqualTo(status) .expectHeader().contentType(APPLICATION_JSON_UTF8) .expectBody(type) .returnResult().getResponseBody(); }
protected <T, K> T post(final Function<UriBuilder, URI> builder, final HttpStatus status, final K object, final Class<T> type) { return client.post() .uri(builder) .body(BodyInserters.fromObject(object)) .accept(APPLICATION_JSON_UTF8).exchange() .expectStatus().isEqualTo(status) .expectHeader().contentType(APPLICATION_JSON_UTF8) .expectBody(type) .returnResult().getResponseBody(); }
public DefaultRequest(UriBuilder uriBuilder, HttpMethod httpMethod, HttpHeaders httpHeaders, Map<String, Object> variables, BodyInserter<?, ? super ClientHttpRequest> bodyInserter) { this.uriBuilder = uriBuilder; this.httpMethod = httpMethod; this.bodyInserter = bodyInserter; this.variables = new HashMap<>(); this.variables.putAll(variables); this.httpHeaders = new HttpHeaders(); this.httpHeaders.putAll(httpHeaders); }
@Override public UriBuilder uriString(String uriTemplate) { VaultEndpoint endpoint = endpointProvider.getVaultEndpoint(); String baseUri = toBaseUri(endpoint); UriComponents uriComponents = UriComponentsBuilder.fromUriString( prepareUriTemplate(baseUri, uriTemplate)).build(); return UriComponentsBuilder.fromUriString(baseUri).uriComponents( uriComponents); }
protected String get(final Function<UriBuilder, URI> builder) { return get(builder, HttpStatus.OK); }
protected <T> T get(final Function<UriBuilder, URI> builder, final Class<T> type) { return get(builder, HttpStatus.OK, type); }
protected <T, K> T post(final Function<UriBuilder, URI> builder, final K object, final Class<T> type) { return post(builder, HttpStatus.OK, object, type); }
public DefaultRequest buildRequest(String uri, Map<String, Object> variables) { UriBuilder uriBuilder = new DefaultUriBuilderFactory(uri).builder(); return new DefaultRequest(uriBuilder, HttpMethod.GET, new HttpHeaders(), variables, BodyInserters.empty()); }