There is a Kotlin variant of the linkTo method of Spring HATEOAS that takes a reified type parameter for the Controller and function for the body:
org.springframework.hateoas.server.mvc WebMvcLinkBuilderDslKt.class public inline fun <reified C> linkTo(
func: C.() → Unit
): WebMvcLinkBuilder
but I have no idea how to actually use it, since I haven't found any useful documentation and the API is not really intuitive. I tried it like this:
linkTo<MyHandler> { findById(req) }.toUriComponentsBuilder().build(mapOf("id" to 1)).toURL()
I think it is wrong to use the req object of the surrounding method, if the link should point to another method. The result is simply http://localhost:8080 without any path or parameter.
How can I build a link with the Kotlin DSL?
Since I'm using Spring WebMvc.fn: Is there another way to build links with this framework?