Sha256: 8914394b4ead1ab8024dda464e5f52f3d5a03936dcaf78ad9aa69310b4552466

Contents?: true

Size: 722 Bytes

Versions: 2

Compression:

Stored size: 722 Bytes

Contents

require 'fozzie/rack/middleware'

module Fozzie
  module Rails
    class Middleware < Fozzie::Rack::Middleware

      def generate_key(env)
        path_str = env['PATH_INFO']
        return nil unless path_str

        begin
          routing = (rails_version == 3 ? ::Rails.application.routes : ::ActionController::Routing::Routes)
          path    = routing.recognize_path(path_str)
          stat    = [path[:controller], path[:action], "render"].join('.')
          stat
        rescue ActionController::RoutingError => exc
          S.increment "routing.error"
          nil
        rescue => exc
          nil
        end
      end

      def rails_version
        ::Rails.version.to_i
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fozzie-0.0.15 lib/fozzie/rails/middleware.rb
fozzie-0.0.14 lib/fozzie/rails/middleware.rb