Filters
Filters allow us to hook into, or intercept, the processing of a request. There are interceptors for before, after, and afterView. There are many uses for filters, and you can have as many filters as you need in an application. In our case, we’ll use a filter to determine whether a user is logged in when they try to access a “secure” page.
This must be sounding like a broken record (does anyone remember what that is?), but Grails makes implementing filters a snap. Create a Groovy class with a name ending in Filters, and place it in the grails-app/conf directory. In this class, define a code block called filters, and then include individual filters as if they were methods. Each filter (method) can take named parameters for controller ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access