use of org.springframework.web.client.RestTemplate in project tutorials by eugenp.
the class ClientConfig method restTemplate.
@Bean
public RestTemplate restTemplate() {
HttpHost host = new HttpHost("localhost", 8080, "http");
CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider()).useSystemProperties().build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactoryDigestAuth(host, client);
return new RestTemplate(requestFactory);
}
use of org.springframework.web.client.RestTemplate in project cetc by DiscoverForever.
the class AnalysisTaskResource method deleteAnalysisTask.
/**
* 删除预警任务
* @param analysisTaskID
* @return
*/
public ResponseEntity<String> deleteAnalysisTask(String analysisTaskID) {
RestTemplate restTemplate = new RestTemplate();
// todo 替换为CETC的api接口
// String url = "http://localhost:3000/test";
String url = "http://192.168.1.168:8099/deepaction/";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", analysisTaskID);
HttpEntity entity = new HttpEntity(map, headers);
String res = restTemplate.exchange(url, HttpMethod.DELETE, entity, String.class).getBody();
return new ResponseEntity<>(res, headers, HttpStatus.OK);
}
use of org.springframework.web.client.RestTemplate in project nakadi by zalando.
the class AuthenticationConfig method restTemplate.
@Bean
public RestTemplate restTemplate(final HttpClient httpClient) {
final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
final RestTemplate restTemplate = new RestTemplate(requestFactory);
restTemplate.setErrorHandler(TokenResponseErrorHandler.getDefault());
return restTemplate;
}
use of org.springframework.web.client.RestTemplate in project webcert by sklintyg.
the class ConsumerConfig method customRestTemplate.
@Bean
public RestTemplate customRestTemplate() {
HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
httpRequestFactory.setConnectionRequestTimeout(requestTimeout);
httpRequestFactory.setConnectTimeout(connectionTimeout);
httpRequestFactory.setReadTimeout(readTimeout);
return new RestTemplate(httpRequestFactory);
}
use of org.springframework.web.client.RestTemplate in project spring-integration by spring-projects.
the class HttpDslTests method testHttpProxyFlow.
@Test
public void testHttpProxyFlow() throws Exception {
RestTemplate mockMvcRestTemplate = new RestTemplate(new MockMvcClientHttpRequestFactory(this.mockMvc));
new DirectFieldAccessor(this.serviceInternalGatewayHandler).setPropertyValue("restTemplate", mockMvcRestTemplate);
this.mockMvc.perform(get("/service").with(httpBasic("admin", "admin")).param("name", "foo")).andExpect(content().string("FOO"));
this.mockMvc.perform(get("/service").with(httpBasic("user", "user")).param("name", "name")).andExpect(status().isForbidden());
}
Aggregations