use of org.springframework.boot.web.client.RestTemplateBuilder in project spring-cloud-gateway by spring-cloud.
the class ProxyResponseAutoConfiguration method proxyExchangeArgumentResolver.
@Bean
@ConditionalOnMissingBean
public ProxyExchangeArgumentResolver proxyExchangeArgumentResolver(Optional<RestTemplateBuilder> optional, ProxyProperties proxy) {
RestTemplateBuilder builder = optional.orElse(new RestTemplateBuilder());
RestTemplate template = builder.build();
template.setErrorHandler(new NoOpResponseErrorHandler());
template.getMessageConverters().add(new ByteArrayHttpMessageConverter() {
@Override
public boolean supports(Class<?> clazz) {
return true;
}
});
ProxyExchangeArgumentResolver resolver = new ProxyExchangeArgumentResolver(template);
resolver.setHeaders(proxy.convertHeaders());
// can be null
resolver.setSensitive(proxy.getSensitive());
return resolver;
}
use of org.springframework.boot.web.client.RestTemplateBuilder in project uhgroupings by uhawaii-system-its-ti-iam.
the class HttpRequestServiceImpl method makeApiRequestWithBody.
/*
* Make an http request to the API with path variables and description in the body.
*/
@SuppressWarnings("lgtm[java/xss]")
@Override
public ResponseEntity<String> makeApiRequestWithBody(String currentUser, String uri, String data, HttpMethod method) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.set(CURRENT_USER, currentUser);
HttpEntity<String> httpEntity = new HttpEntity<>(data, httpHeaders);
RestTemplate restTemplate = new RestTemplateBuilder().errorHandler(new RestTemplateResponseErrorHandler()).build();
return restTemplate.exchange(uri, method, httpEntity, String.class);
}
Aggregations