-
Notifications
You must be signed in to change notification settings - Fork 470
Enabling hypermedia disables all of WebFlux's default codecs #1061
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
Okay, this was originally put in because something about the order of custom registered mediatype handlers and the defaults didn't work right. I'm happy to report that appears to no longer be an issue. Flipping to The one failing test case is where Switching to @Configuration
@EnableWebFlux
static abstract class BaseConfig {
@Bean
TestController testController() {
return new TestController();
}
}
@EnableHypermediaSupport(type = HAL)
static class HalWebFluxConfig extends BaseConfig {} @GetMapping
RepresentationModel<?> root() {
RepresentationModel<?> root = new RepresentationModel<>();
root.add(new Link("/").withSelfRel());
root.add(new Link("/employees").withRel("employees"));
return root;
} @Test
void callingForUnregisteredMediaTypeShouldFail() {
setUp(HalWebFluxConfig.class);
this.testClient.get().uri("/").accept(MediaTypes.UBER_JSON) //
.exchange() //
.expectStatus().isOk() //
.returnResult(String.class) //
.getResponseBody() //
.as(StepVerifier::create) //
.expectNextMatches(s -> {
return true;
}) //
.verifyComplete();
} it yields the following JSON: This is basically falling back to no registered codec, and rendering the Spring HATEAOS I'm frankly uncertain how to proceed with this. If the server can't produce |
Do we need to register a special handler/filter in WebFlux to cover unregistered media types and then throw an exception? |
The media type isn't unregistered. The default WebFlux In some cases, Does the same problem not also occur with MVC? |
Verified that Spring MVC indeed returns a Jackson-based piece of JSON when calling for an unregistered mediatype. This means I can switch back to default encoders/decoders for WebFlux configuration. |
Spring WebFlux now correctly handles custom codecs. This means we can stop disabling them. This change includes more test cases, verifying Spring MVC configuration for hypermedia as well, verifying both Web MVC and WebFlux are properly and consistently configured. Probably supercedes: #1047
With Spring WebFlux properly handling custom codecs, no need to disable the default handlers. This commit verifies WebFlux configuration in test cases, and also adds an equivalent set of test cases verifying Web MVC configuration as well. Supercedes: #1047
Resolved via fd70fd9. |
If I
@EnableHypermediaSupport
, all of the default server codes are lost:spring-hateoas/src/main/java/org/springframework/hateoas/config/WebFluxHateoasConfiguration.java
Line 141 in e5669ee
As far as I can tell, this makes Spring HATEOAS difficult to use in a WebFlux application that doesn't solely contain HATEOAS-based endpoints. It's also a significant departure from using HATEOAS with Spring MVC where the Web MVC customisations are additive.
The text was updated successfully, but these errors were encountered: