-
Notifications
You must be signed in to change notification settings - Fork 471
Add Spring WebFlux support #728
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
There is no WebFlux support at this point in time. |
And it's sad, at the moment I have to do some ugly weird stuff like: @Bean
fun routes() = router {
"/".nest {
// ...
GET("/**") {
val url = it.uri().toURL()
val baseURL = "${url.protocol}://${url.authority}"
ok().body(mapOf(
"_links" to listOf(
mapOf(
"rel" to "search",
"href" to "$baseURL/api/search?query={searchQuery}",
"templated" to true
),
mapOf(
"rel" to "details",
"href" to "$baseURL/api/details/{userId}",
"templated" to true
),
mapOf(
"rel" to "_self",
"href" to url,
"templated" to false
)
)
).toMono())
}
}
} Thanks to Kotlin it's not so verbose, but things get worst by using java... In this case some additional code needed to wrap it in some links builder.. It would be nice to have at least some filter which could be configured and used like so: @Bean
fun routes() = router {
"/".nest {
// ...
GET("/**") {
// ..
}
}
}.filter { request, next -> hateoasFilter(request, next) } Regards, |
@gregturn Any play on adding support for webflux? |
During S1P back in September, plans were formed to add WebFlux support to Spring HATEOAS. We haven't gotten underway with implementing, though. There was a stack of other stuff in the works that we are fervently hammering on. Stay tuned! |
* Render hypermedia from WebFlux controllers. * Support consuming hypermedia through WebClient. * Support link creation reactively with a custom filter and explicitly with a user-provided ServerWebExchange. * Add a ReactiveResourceAssembler and SimpleReactiveResourceAssembler. * Upgrade to Spring Framework 5.2 to align with Spring Data Moore, removing specialized Forwarded header handling.
WebFlux support is now under review. |
Improving some JavaDoc. Adding issue references to tests. Updating copyright notice.
* Render hypermedia from WebFlux controllers. * Support consuming hypermedia through WebClient. * Support link creation reactively with a custom filter and explicitly with a user-provided ServerWebExchange. * Add a ReactiveResourceAssembler and SimpleReactiveResourceAssembler. * Upgrade to Spring Framework 5.2 to align with Spring Data Moore, removing specialized Forwarded header handling.
* Improving some JavaDoc. * Adding issue references to tests. * Updating copyright notice.
* Fix up issues reported by Jens. * Add extra tests showing encoding as well as decoding. * Properly handle Reactor types on WebFlux inputs. * Update CI to account for the upgrade to Spring Framework 5.2.
* Fix up issues reported by Jens. * Add extra tests showing encoding as well as decoding. * Properly handle Reactor types on WebFlux inputs. * Update CI to account for the upgrade to Spring Framework 5.2.
* Render hypermedia from WebFlux controllers. * Support consuming hypermedia through WebClient. * Support link creation reactively with a custom filter and explicitly with a user-provided ServerWebExchange. * Add a ReactiveResourceAssembler and SimpleReactiveResourceAssembler. * Upgrade to Spring Framework 5.2 to align with Spring Data Moore, removing specialized Forwarded header handling.
Adapt to API changes in master branch. Fixed formatting.
WebHandler is now independent of a particular web stack as the final LinkBuilder creation is externalized through a SAM type that client code now uses to pass a constructor. Refactored the ReactiveLinkBuilder to avoid a dependency on ControllerLinkBuilder (read: the WebMVC stack). With that change, WebHandler is now moved back to the core package. Refactored LinkBuilderSupport to keep a UriComponentsBuilder instance around instead of UriComponents. It creates a defensive copy of the builder instance on state modifying invocations and returns a new LinkBuilderSupport instance. Moved SpringMvcAffordanceBuilder to the core package and removed Mvc segment from its name to make obvious it's not tied to SpringMVC. Introduced TemplateVariableAwareLinkBuilderSupport as common base class between ControllerLinkBuilder and ReactiveLinkBuilder. It extracts the TemplateVariable behavior from ControllerLinkBuilder. Extracted import of web stack specific configuration into dedicated ImportSelector and make use of String based class names to avoid cyclic dependencies between the config packages. Removed BasicLinkBuilder.
Renamed LinkBuilder implementations for the different web stacks Web(MVC|Flux)LinkBuilder for symmetry. Introduced dedicated builder types to be used from WebFluxLinkBuilder to more conveniently integrate with reactive flows (see the changes in WebFluxEmployeeController). Deprecated ControllerLinkBuilder(Factory) in favor of WebMvcLinkBuilder(Factory). Generally untangled the use of WebMvcLinkBuilder from the reactive examples.
Renamed LinkBuilder implementations for the different web stacks Web(MVC|Flux)LinkBuilder for symmetry. Introduced dedicated builder types to be used from WebFluxLinkBuilder to more conveniently integrate with reactive flows (see the changes in WebFluxEmployeeController). Deprecated ControllerLinkBuilder(Factory) in favor of WebMvcLinkBuilder(Factory). Generally untangled the use of WebMvcLinkBuilder from the reactive examples.
* Render hypermedia from WebFlux controllers. * Support consuming hypermedia through WebClient. * Support link creation reactively with a custom filter and explicitly with a user-provided ServerWebExchange. * Add a ReactiveResourceAssembler and SimpleReactiveResourceAssembler. * Upgrade to Spring Framework 5.2 to align with Spring Data Moore, removing specialized Forwarded header handling.
Adapt to API changes in master branch. Fixed formatting.
WebHandler is now independent of a particular web stack as the final LinkBuilder creation is externalized through a SAM type that client code now uses to pass a constructor. Refactored the ReactiveLinkBuilder to avoid a dependency on ControllerLinkBuilder (read: the WebMVC stack). With that change, WebHandler is now moved back to the core package. Refactored LinkBuilderSupport to keep a UriComponentsBuilder instance around instead of UriComponents. It creates a defensive copy of the builder instance on state modifying invocations and returns a new LinkBuilderSupport instance. Moved SpringMvcAffordanceBuilder to the core package and removed Mvc segment from its name to make obvious it's not tied to SpringMVC. Introduced TemplateVariableAwareLinkBuilderSupport as common base class between ControllerLinkBuilder and ReactiveLinkBuilder. It extracts the TemplateVariable behavior from ControllerLinkBuilder. Extracted import of web stack specific configuration into dedicated ImportSelector and make use of String based class names to avoid cyclic dependencies between the config packages. Removed BasicLinkBuilder.
Renamed LinkBuilder implementations for the different web stacks Web(MVC|Flux)LinkBuilder for symmetry. Introduced dedicated builder types to be used from WebFluxLinkBuilder to more conveniently integrate with reactive flows (see the changes in WebFluxEmployeeController). Deprecated ControllerLinkBuilder(Factory) in favor of WebMvcLinkBuilder(Factory). Generally untangled the use of WebMvcLinkBuilder from the reactive examples.
* Render hypermedia from WebFlux controllers. * Support consuming hypermedia through WebClient. * Support link creation reactively with a custom filter and explicitly with a user-provided ServerWebExchange. * Add a ReactiveResourceAssembler and SimpleReactiveResourceAssembler. * Upgrade to Spring Framework 5.2 to align with Spring Data Moore, removing specialized Forwarded header handling.
Adapt to API changes in master branch. Fixed formatting.
WebHandler is now independent of a particular web stack as the final LinkBuilder creation is externalized through a SAM type that client code now uses to pass a constructor. Refactored the ReactiveLinkBuilder to avoid a dependency on ControllerLinkBuilder (read: the WebMVC stack). With that change, WebHandler is now moved back to the core package. Refactored LinkBuilderSupport to keep a UriComponentsBuilder instance around instead of UriComponents. It creates a defensive copy of the builder instance on state modifying invocations and returns a new LinkBuilderSupport instance. Moved SpringMvcAffordanceBuilder to the core package and removed Mvc segment from its name to make obvious it's not tied to SpringMVC. Introduced TemplateVariableAwareLinkBuilderSupport as common base class between ControllerLinkBuilder and ReactiveLinkBuilder. It extracts the TemplateVariable behavior from ControllerLinkBuilder. Extracted import of web stack specific configuration into dedicated ImportSelector and make use of String based class names to avoid cyclic dependencies between the config packages. Removed BasicLinkBuilder.
Renamed LinkBuilder implementations for the different web stacks Web(MVC|Flux)LinkBuilder for symmetry. Introduced dedicated builder types to be used from WebFluxLinkBuilder to more conveniently integrate with reactive flows (see the changes in WebFluxEmployeeController). Deprecated ControllerLinkBuilder(Factory) in favor of WebMvcLinkBuilder(Factory). Generally untangled the use of WebMvcLinkBuilder from the reactive examples.
This is now in place with |
Hey, @odrotbohm! |
Really big thanks 😃 |
Hello, @odrotbohm, @gregturn or maybe someone else, guys maybe you have some examples where I can look how I can use Sorry if I'm asking dumb questions, but I wasn't able to find anything specific yet in here: https://docs.spring.io/spring-hateoas/docs/1.0.0.BUILD-SNAPSHOT/reference/html/ and in tests Thanks in advice Regards, |
It's all in quite a flux (pun intended) right now. The most practical place to look at right now is the sample controller we use in the test cases. Updating the docs is high priority, but I'm not sure we're gonna get it done in time before 1.0 M1. |
Thanks a lot! |
Tweaked WebFluxLinkBuilder to make sure the controller invocations are resolved eagerly as otherwise, the controller proxy created would override the invocations due to the lazy evaluation of the links and for multiple method references, only the last one would have been used.
@odrotbohm any news at docs for hateoas with WebFlux? |
Hello,
Are there any options for spring-webflux functional routes?
Regards,
Maksim
The text was updated successfully, but these errors were encountered: