GET("{id}/hello") would be what I would have used
# spring
k
GET("{id}/hello") would be what I would have used
s
kenkyee: That would indeed work as GET("/{id}/hello"). But obviously this is a trivialized simple example that doesn't work as I would expect. The idea is to add nested routes programmatically. Something like:
Copy code
val nestedRouteMap : Map<String,Routes> = getItSomewhere()
"/".route {
  ...
  "/{id}".route {
    nestedRouteMap.forEach {
      "/${it.key}".route(it.value)
    }
  }
}
k
Is there a use case for this? I haven't used this new spring feature yet... We've always done it the other way...
s
sure there is a use case ... i was successful in implementing basically an abstract CRUD "router" which would work for every entity type with the basic GET/POST/PUT/DELETE functionality. The controller also allows an extension point to add nested routes for additional functionality for each entity
k
Ahhh.. Interesting. We've always done different endpoints for different types.
s
Yeah, with the new functional webflux APIs it is now possible to do stuff that traditional annotation approach does not allow. Although I'm mindful of descending into NodeJS style "callback hell". Hopefully it won't happen.