I have configured some restful resources in grails like this
"/book/$id?"(resource:"book")
"/author/$id?"(resource:"author")
But I want to to this more generic like
"/$controller/$id?"(resource: controller)
which doesn't work... (getting 404)
How can i configure a generic url mapping for restful resources in grails?
It would seem that the "resource" portion of the mapping is evaluated on startup, not on execution of the actual request (a guess from playing around with this). Therefore, I think you need to "preload" the set of UrlMappings you want dynamically based on the Domain classes available on application startup. Something like this might do the trick:
class UrlMappings {
static mappings = {
ApplicationHolder.application.getArtefacts('Domain').each { GrailsClass cl ->
"/${cl.propertyName}/$id?"(resource: cl.propertyName )
} ...