module Immunio module MetalHook extend ActiveSupport::Concern included do if method_defined? :dispatch Immunio::Utils.alias_method_chain self, :dispatch, :immunio end end protected def dispatch_with_immunio(*args) Request.time 'plugin', "#{Module.nesting[0]}::#{__method__}" do name, _ = *args route_name = "#{controller_path}##{name}" Immunio.logger.debug { "MetalHook#dispatch: route_name: #{route_name}" } Immunio.run_hook! 'metal', 'framework_route', route_name: route_name Request.pause "plugin", "#{Module.nesting[0]}::#{__method__}" do dispatch_without_immunio(*args) end end end end end Immunio::Plugin.load( 'ActionController (Metal)', hooks: %w(framework_route)) do |plugin| ActionController::Metal.send :include, Immunio::MetalHook plugin.loaded! ActionPack::VERSION::STRING end