lib/rack/fraction.rb
# Implementation of the middleware automatically called by Rack
#
# @param [Hash] env rack app env automatically passed to the middleware
#
# @return [Rack::Response] response after either calling original app and modifying response
#   or calling the app with modified environment and returning its response
Implementation of the middleware automatically called by Rack
Implementation of the middleware automatically called by Rack
def call(env)
      if rand(1..100) <= @percent
        if @modify == :response
          response = @handler.call(*@app.call(env))
        else 
          modified_env = @handler.call(env) || env
          response = @app.call(modified_env)
        end
      else
        response = @app.call(env)
      end
      response
    end
def call ( env ) if rand ( 1 .. 100 ) <= @percent if @modify == :response response = @handler . call ( * @app . call ( env ) ) else modified_env = @handler . call ( env ) || env response = @app . call ( modified_env ) end else response = @app . call ( env ) end response end
Implementation of the middleware automatically called by Rack
Implementation of the middleware automatically called by Rack
# status, headers, body # :env
response after either calling original app and modifying response or calling the app with modified environment and returning its response
response after either calling original app and modifying response or calling the app with modified environment and returning its response
Rack::Response
env
env rack app env automatically passed to the middleware
env rack app env automatically passed to the middleware