Sha256: fb0049732d3193ee8b32e1ec2947889d0f87cd5a409c42f7ea364b3188f99bcc

Contents?: true

Size: 471 Bytes

Versions: 3

Compression:

Stored size: 471 Bytes

Contents

class Deadweight
  module Rack
    class CapturingMiddleware
      def initialize(app, dw)
        @app = app
        @dw  = dw
      end

      def call(env)
        response = @app.call(env)
        process(response)
        response
      end

      def process(rack_response)
        status, headers, response = rack_response

        if response.respond_to?(:body)
          html = response.body
          @dw.process!(html)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
deadweight-0.2.2 lib/deadweight/rack/capturing_middleware.rb
deadweight-0.2.1 lib/deadweight/rack/capturing_middleware.rb
deadweight-0.2.0 lib/deadweight/rack/capturing_middleware.rb