Sha256: 5adb56dae7d0bafe7fc903f4ca65fdc80b915a51dea6056ed803805e16563b81

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

require 'active_support/hash_with_indifferent_access'

module Newark
  class Request < Rack::Request

    def initialize(*)
      super
      @body    = @env["rack.input"].clone.read
      @params  = ActiveSupport::HashWithIndifferentAccess.new(params)
      @headers = original_headers
    end

    def uri
      URI(base_url + fullpath)
    end

    def body
      @body
    end

    protected

    def original_headers
      {}.tap do |headers|
        env.select { |k, v| k.start_with?('HTTP_') }.each_pair do |k, v|
          header = k.sub(/^HTTP_/, '').split('_').map(&:capitalize).join('-')
          headers[header] = v
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
newark-0.0.1 lib/newark/request.rb