Sha256: 402cc836b30e2e8555516a39b58e289a6421af4f841722a942b3c886896ea4fd

Contents?: true

Size: 698 Bytes

Versions: 2

Compression:

Stored size: 698 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)

          [path[:controller], path[:action], "render"].join('.')
        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.13 lib/fozzie/rails/middleware.rb
fozzie-0.0.12 lib/fozzie/rails/middleware.rb