spring-projects / spring-projects/spring-hateoas
Access HAL+JSON resources using RestTemplate from RestTemplateBuilder
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
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 injecting RestTemplateBuilder.
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 any RestTemplate bean in the application context (using ConverterRegisteringWebMvcConfigurer), but it doesn't affect RestTemplateBuilder.
For that I have to define the following RestTemplateCustomizer (based on this comment):
@Configuration
@EnableHypermediaSupport(type = HAL)
class HalConfiguration {
@Bean
RestTemplateCustomizer halRestTemplateCustomizer(ConverterRegisteringWebMvcConfigurer configurer) {
return template -> configurer.extendMessageConverters(template.getMessageConverters());
}
}
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 HttpMessageConverters.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading ConverterRegisteringBeanPostProcessor and ConverterRegisteringWebMvcConfigurer, then compare how RestTemplateBuilder creates templates and how RestTemplateCustomizer is applied. Determine how hypermedia-enabled HttpMessageConverters should reach builder-created RestTemplate instances, and verify that the existing customizer workaround is no longer required.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100