简体   繁体   中英

Grails filters: can uri and uriExclude be used in the same filter?

I've defined a filter in grails like so:

securityFilter(uri: '/api/**', uriExclude: '/api/**/*skipthis*') {
   before {
       ...
       println request.url
   }
}

I was expecting it to handle any requests like /api/mything but ignore requests like /blahblah/mything/ and /api/mything/andskipthisthing requests yet my log reveals it's dutifully looking at /blahblah/mything

I understand that excludes take precedence, but I would have thought that would mean it would still only look at anything under /api/ . I haven't seen any examples of excludeUri in my searches, and all the uri examples I see only use the uri and nothing else. Are we allowed to use excludeUri and uri together? Is this a bug in grails?

Doh! I was looking at request.requestURL , which is the grails dispatcher url (ends with .dispatch ) ... What I wanted was the request.forwardURI

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM