class RailsMiniProfiler::RequestWrapper
A convenience wrapper around [Rack::Env]
@!attribute body
@return [String] the request body
@!attribute method
@return [String] the request method
@!attribute path
@return [String] the request path
@!attribute query_string
@return [String] the request query string
@!attribute env
@return [Rack::Env] the original env
@api private
Attributes
body[R]
env[R]
method[R]
path[R]
query_string[R]
Public Class Methods
new(*_args, **attributes)
click to toggle source
# File lib/rails_mini_profiler/request_wrapper.rb, line 25 def initialize(*_args, **attributes) @attributes = attributes setup end
Public Instance Methods
headers()
click to toggle source
The request headers
@return [Hash] the headers
# File lib/rails_mini_profiler/request_wrapper.rb, line 33 def headers @attributes[:headers] || @env.select { |k, _v| k.start_with? 'HTTP_' } || {} end
Private Instance Methods
setup()
click to toggle source
# File lib/rails_mini_profiler/request_wrapper.rb, line 39 def setup @env = @attributes[:env] || {} @method = setup_method @query_string = setup_query_string @path = setup_path @body = setup_body end
setup_body()
click to toggle source
# File lib/rails_mini_profiler/request_wrapper.rb, line 59 def setup_body return @attributes[:body] if @attributes[:body] return '' unless @env['rack.input'] body = @env['rack.input'].read @env['rack.input'].rewind body end
setup_method()
click to toggle source
# File lib/rails_mini_profiler/request_wrapper.rb, line 47 def setup_method @attributes[:method] || @env['REQUEST_METHOD'] || 'GET' end
setup_path()
click to toggle source
# File lib/rails_mini_profiler/request_wrapper.rb, line 55 def setup_path @attributes[:path] || @env['PATH_INFO'] || '/' end
setup_query_string()
click to toggle source
# File lib/rails_mini_profiler/request_wrapper.rb, line 51 def setup_query_string @attributes[:query_string] || @env['QUERY_STRING'] || '' end