views:

280

answers:

1

I have the following identical code-block in all my controllers' beforeInterceptor blocks:

def beforeInterceptor = {
  request.someField = Foo.someFoo(request)
  if (!request.someField) {
    redirect(...)
    return
  }
}

Repeating the exact same code fragment in all controllers violates DRY. Is there some standard Grails way to define a "global" beforeInterceptor?

+3  A: 

A Filter can be used to apply before/after logic across a group of controllers, a URI or to a specific action.

John Wagenleitner