Hello,
Are there any options for spring-webflux functional routes?
Regards,
Maksim
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,
Maksim Kostromin
@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!
WebFlux support is now under review.
This is now in place with WebFluxLinkBuilder API providing a reactive builder for calls to linkTo(…). Feel free to give the latest snapshots a try. Feedback highly appreciated!
Hey, @odrotbohm!
Awesome! Thanks! I will try, for sure
Really big thanks 😃
Hello,
@odrotbohm, @gregturn or maybe someone else, guys maybe you have some examples where I can look how I can use WebFluxLinkBuilder? Is it required using Spring MVC styled Resources only? If not, can you please quickly show how I can use it together with functional routes?
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,
Max
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!
@odrotbohm any news at docs for hateoas with WebFlux?
Most helpful comment
This is now in place with
WebFluxLinkBuilderAPI providing a reactive builder for calls tolinkTo(…). Feel free to give the latest snapshots a try. Feedback highly appreciated!