/**
* register specific RestTemplate in Spring Application Context if needed
*/
private Consumer<Application> createRestTemplateBasicAuth(ConfigurableListableBeanFactory registry) {
return app -> {
// Create rest template instance
RestTemplate restTemplateBasicAuth = defaultRestTemplateConfig.restTemplate(requestFactory, Arrays.asList(defaultRestTemplateConfig.getDefaultAcceptHeader(), MediaType.ALL));
// Configure it with BASIC auth
restTemplateBasicAuth.getInterceptors().add(new BasicAuthorizationInterceptor(app.getActuatorUsername(), app.getActuatorPassword()));
LOGGER.info("Registered RestTemplate with BASIC auth for application with id {}", app.getId());
// Add bean in Spring application context
registry.registerSingleton(getRestTemplateBeanName(app), restTemplateBasicAuth);
};
}
RestTemplateFactory.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:Persephone
作者:
评论列表
文章目录