spring-hateoas
spring-hateoas copied to clipboard
#1047 - Properly respond to application/json calls.
Spring HATEAOS must be strict in what it registers, thus NOT use WebFlux's defaults. Yet it should register at least it's HAL-based media types for application/json, the default type used by testing toolkits such as WebTestClient. That way, if you craft a controller that does not deal with hypermedia, it will function as expected.
That is why I've expanded HypermediaMappingInformation to include a getRegisterableMediaTypes method. By default, it simply returns the results of getMediaTypes. But certain media types, like HAL and HAL-FORMS, can add application/json as a media type they will respond to if asked. This provides the means to support other formats using the same serializers.
I'd love to get on a quick call with @rstoyanchev this week to discuss this approach. My first reaction towards the solution was rather conservative as I am not sure we want to expose this problem in the SPI as to me it seems like a end user decision which of the JSON-based media types is supposed to be the one to be returned for a request asking for application/json, not the the media type implementor.