Sha256: ddd9d38c39c43342d4c00c4a3929fb841f16d379850c47e9832e00186ae1ec1a

Contents?: true

Size: 1.17 KB

Versions: 63

Compression:

Stored size: 1.17 KB

Contents

require 'webmachine/request'
require 'webmachine/adapters/rack'

# Monkey patch to make the Rack env available on the Webmachine Request object

module Webmachine
  class RackRequest < Webmachine::Request
    attr_reader :env

    def initialize(method, uri, headers, body, routing_tokens, base_uri, env)
      super(method, uri, headers, body, routing_tokens, base_uri)
      @env = env
    end
  end
end

unless Webmachine::Adapters::Rack.private_instance_methods.include?(:build_webmachine_request)
  raise "Webmachine::Adapters::Rack no longer has the private instance method #build_webmachine_request - rack env monkey patch won't work"
end

module Webmachine
  module Adapters
    class Rack < Adapter
      private

      def build_webmachine_request(rack_req, headers)
        Webmachine::RackRequest.new(rack_req.request_method,
                                rack_req.url,
                                headers,
                                RequestBody.new(rack_req),
                                routing_tokens(rack_req),
                                base_uri(rack_req),
                                rack_req.env
                               )
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
pact_broker-2.79.1 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.79.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.78.1 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.78.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.77.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.76.2 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.76.1 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.76.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.75.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.74.1 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.74.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.73.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.72.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.71.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.70.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.69.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.68.1 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.68.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.67.0 lib/webmachine/rack_adapter_monkey_patch.rb
pact_broker-2.66.0 lib/webmachine/rack_adapter_monkey_patch.rb