Class: Newark::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/newark/request.rb

Instance Method Summary collapse

Instance Method Details

#bodyObject



23
24
25
# File 'lib/newark/request.rb', line 23

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

#headersObject



27
28
29
# File 'lib/newark/request.rb', line 27

def headers
  @headers ||= original_headers
end

#paramsObject



19
20
21
# File 'lib/newark/request.rb', line 19

def params
  @params ||= ActiveSupport::HashWithIndifferentAccess.new(super)
end

#path_infoObject



15
16
17
# File 'lib/newark/request.rb', line 15

def path_info
  @path_info ||= super == '/' ? super : super.sub(/\/$/, '')
end

#request_idObject



31
32
33
34
# File 'lib/newark/request.rb', line 31

def request_id
  @env['action_dispatch.request_id'] ||
  (@env['rack.request_id'] ||= headers['X-Request-Id'] || SecureRandom.uuid)
end

#uriObject



7
8
9
10
11
12
13
# File 'lib/newark/request.rb', line 7

def uri
  uri = "#{scheme}://#{host_with_port}#{path_info}"
  uri << "?#{query_string}" unless query_string.empty?
  URI(uri)
rescue URI::InvalidURIError
  URI(URI.escape(uri))
end