-
Notifications
You must be signed in to change notification settings - Fork 472
Access HAL+JSON resources using RestTemplate from RestTemplateBuilder #1049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am on the same project as @mkhl. Now we use for 1.0.1-RELEASE following workaround to register the HAL converter: @Configuration
public class RestTemplateConfig {
@Bean
RestTemplateCustomizer halRestTemplateCustomizer(List<WebMvcConfigurer> configurers) {
WebMvcConfigurer webMvcConfigurer = configurers.stream()
.filter(configurer -> configurer.getClass().getCanonicalName().contains("org.springframework.hateoas"))
.findFirst()
.get();
return template -> webMvcConfigurer.extendMessageConverters(template.getMessageConverters());
}
} As WebMvcConfigurer is package-private we cannot access it directly. |
(He means |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using Spring 5.1.8, Spring Boot 2.1.6, and Spring HATEOAS 0.25.1.
I want to construct the
RestTemplate
in the using@Component
by injectingRestTemplateBuilder
.This seems to be the recommended way and allows different components to define their own error handling instead of sharing it across components.
ConverterRegisteringBeanPostProcessor
configures anyRestTemplate
bean in the application context (usingConverterRegisteringWebMvcConfigurer
), but it doesn't affectRestTemplateBuilder
.For that I have to define the following
RestTemplateCustomizer
(based on this comment):It seems to me that (something like) this would make sense to include in spring-hateoas.
Alternatively, it would be nice if there were an easier way to access or inject hypermedia-enabled
HttpMessageConverter
s.The text was updated successfully, but these errors were encountered: