Skip to content
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

#1047 - Properly respond to application/json calls. #1048

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gregturn
Copy link
Contributor

@gregturn gregturn commented Aug 9, 2019

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.

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.
@gregturn gregturn requested a review from odrotbohm August 9, 2019 22:33
@odrotbohm
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants