I'm trying to convert a Grails 2 controller filter into a Grails 3 interceptor. The interceptor is in a Grails plugin. The Grails 3 upgrade is done, and when I copy and paste the code into an app (just to verify it works), then I see the output from the interceptor.
However, if I try to pull in that code through a plugin to the app, the interceptors do not run. I can verify that the plugin is being pulled; its interceptors are just not being invoked when I hit an action.
For example if the plugin is:
// If added to app directly, works fine. As plugin, not invoked.
class SimpleInterceptor {
SimpleInterceptor() {
matchAll()
}
boolean before() {
println 'test' // Does not print if using plugin
}
}
And the controller is a simple action:
def index() {
render 'success'
}
Do I need to register it somehow in order for the interceptor to work on apps? Am I missing a step?
Thanks to @vahid for pointing out a repo that was doing something similar. Turns out the issue I had was when I upgraded my plugin's *Plugin.groovy
file, I didn't extend grails.plugins.Plugin
. Be sure to do that, or the plugin may not get picked up by apps.
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.