An Interceptor is a function that is invoked by the framework BEFORE or AFTER an action invocation. It allows a form of Aspect Oriented Programming, which is useful for some common concerns such as:

Interceptorsmeaning

Add the filter revel.BeforeAfterFilter to revel.Filters on app/init.go. Ensure your function names match func (c Application) Before() (r revel.Result, a Application)

InterceptorsAngular

Image

Interceptorsdrainage

Notice along with the revel.Result we return the Controller type. This is so when the application starts up it can determine which method belongs to what field in the controller (currently Go does not tell you this information). These work identical to the revel.Interceptors without any configuration.

On the Before method the deepest embedded struct with the Before method is run first, then the next deepest and so on until the top level. After, Finally, Panic are run from the top down

Controllers that have methods named Before,After,Finally,Panic, will be called in the same manner as the interceptor does. The method signature is a little different then normal to allow for method Overriding and cascades. ie if Application has GorpController controller embedded inside it and both define the Before method then what happens is the GorpController.Before is invoked before the Application.Before. The method signature must match the following syntax