Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude Grails filter from 2 (or more) controllers

Tags:

grails

I have a Grails filter that I want to execute for every controller except 2 (SimpleCaptchaController and ApiController). I've been looking at the Grails docs that describe how to define which controllers/actions/views a filter should be applied to, and there doesn't seem to be any obvious way to exclude a filter from 2 or more controllers.

I tried the following:

allExceptTwo(controller: 'simpleCaptcha', uri: '/api/**', invert: true)

But it seems you're not allowed to use controller and api together.

like image 368
Dónal Avatar asked Jan 13 '23 03:01

Dónal


1 Answers

Have you tried a simple regex like this:

allExceptTwo(controller: 'simpleCaptcha|api', invert: true)

I've done something like this before and it works.

Note: I think stop-restart of app is necessary for changes to filters to get picked up.

like image 84
ikumen Avatar answered Jan 17 '23 14:01

ikumen