Sha256: ce7f7425de9f1011b6c7cfc03e6b1eb0e59d3a8cff5258ad283fe2ca91cfcfe0

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

class Remnant
  class Rack
    def initialize(app)
      @app = app
    end

    def call(env)
      @response = [500, '', '']

      if env['REQUEST_PATH'] && env['REQUEST_PATH'].include?('/asset')
        @response = @app.call(env)
      else

        begin
          # only gc capture as dev
          if env['rack.request.cookie_hash']['developer'] == '1'
            ::Remnant::GC.enable_stats
          end

          # record request time
          ::Remnant::Discover.measure('request') do
            @response = @app.call(env)
          end

          # collect & clear stats for next request
          ::Remnant.collect

          # only gc capture as dev
          if env['rack.request.cookie_hash']['developer'] == '1'
            ::Remnant::GC.clear_stats
          end

          ::Rails.logger.flush if ::Rails.logger.respond_to?(:flush)
        rescue ::Exception => exception
          if defined?(Flail)
            Flail::Exception.new(env, exception).handle!
          end

          raise
        end
      end

      @response
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
remnant-0.9.3 lib/remnant/rack.rb
remnant-0.9.2 lib/remnant/rack.rb