Sha256: efea3526927ef409a009262ed11fd8403b65af9e78df8899b7b29afde3dcb789

Contents?: true

Size: 673 Bytes

Versions: 7

Compression:

Stored size: 673 Bytes

Contents

# frozen_string_literal: true

module RailsMiniProfiler
  class RequestWrapper
    attr_reader :body,
                :method,
                :path,
                :query_string,
                :env

    def initialize(env = {})
      @env = env
      @method = @env['REQUEST_METHOD'] || 'GET'
      @query_string = @env['QUERY_STRING'] || ''
      @path = @env['PATH_INFO'] || '/'
      @body = read_body
    end

    def headers
      @env.select { |k, _v| k.start_with? 'HTTP_' } || []
    end

    private

    def read_body
      return '' unless @env['rack.input']

      body = @env['rack.input'].read
      @env['rack.input'].rewind
      body
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_mini_profiler-0.3.0 lib/rails_mini_profiler/request_wrapper.rb
rails_mini_profiler-0.2.1 lib/rails_mini_profiler/request_wrapper.rb
rails_mini_profiler-0.2.0 lib/rails_mini_profiler/request_wrapper.rb
rails_mini_profiler-0.1.3 lib/rails_mini_profiler/request_wrapper.rb
rails_mini_profiler-0.1.2 lib/rails_mini_profiler/request_wrapper.rb
rails_mini_profiler-0.1.1 lib/rails_mini_profiler/request_wrapper.rb
rails_mini_profiler-0.1.0 lib/rails_mini_profiler/request_wrapper.rb