I want to add an interceptor (plug) that is controller/action aware. As far as I know, it’s the router that calls the controller actions, so if I add my plug after the router, the plug can’t prevent the actions being called, but if I insert it before the router, then I can’t get the controller module or the action name in the plug.
I know it’s doable by overriding
Phoenix.Controller.action/2 with some metaprogramming magic, but I don’t want to do this because
action/2 may be further overridden in the controller modules, and I don’t know what will happen if it is overridden twice and calls
super in any of the implementations.
Is there a more clean way to achieve my goal?