In order to send appropriate response, I need to detect whether the controller action has been requested by a classic HTTP GET request, an AJAX request or a g:include tag lib.
For instance, considering the following snippet code:
class CommunityController {
def show = {
def users = getUsers()
if (/* WHAT IS THE CODE HERE??? */) //g:include request => render 'show' template only
render template:'show', model=[users]
else if (request.xhr) //Ajax => we send JSON content
render users as JSON
else //Classic request => we render 'show' GSP page
[users]
}
}
...how can I detect that the action has been called via a g:include tag lib?
Thank you.