Pass parameter in GET action for path in mappings?

I am getting an error in my app when I try to call a dynamic callback for the mappings of an oath endpoint:

mappings {
    if(settings?.controllers) {
        settings?.controllers?.each { contID ->
                path("/dashboard/${contID}") { action: [ GET: "buildDashboard(\"${contID}\")"] }
        }
    }
}

The error is:
groovy.lang.MissingMethodException: No signature of method: buildDashboard("######")() is applicable for argument types: () values: [] (buildDashboard("######"))

Where I've replaced the controllerID with #####. The URL for the endpoint is being created fine, but the error happens when the callback is called.
I've tried no quotes for the parameter, single quotes, and double quotes.

But I clearly have this method in my app code:
def buildDashboard(devId) {
....
}

I'm beginning to think passing a dynamic variable in the callback is not allowed. Help?

Figured out the way to do this:

mappings {
    path("/dashboard/:controllerID") { action: [ GET: "buildDashboard"] }
}

def buildDashboard() {
   def controllerID = params.controllerID
....
}
1 Like