In an interceptor I have this code:
render(contentType: 'text/json') {
msg 'Message to show'
}
It is not possible to add the @CompileStatic
annotation on this interceptor, as the msg
variable isn't declared.
Is there any way to write this in a "compilestatic" friendly way?
Use the json builder directly
def json = new JsonBuilder()
json.call([msg: 'Message to show'])
render(text: json.toString(), contentType: 'text/json')