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(name, request) Request.time 'plugin', "#{Module.nesting[0]}::#{__method__}" do 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 name, request 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