Class: CrashdeskRack::RackContext
- Inherits:
-
Crashdesk::ContextBase
- Object
- Crashdesk::ContextBase
- CrashdeskRack::RackContext
- Defined in:
- lib/crashdesk-rack/rack_context.rb
Instance Method Summary collapse
- #framework ⇒ Object
- #framework_version ⇒ Object
- #headers ⇒ Object
-
#initialize(env, request) ⇒ RackContext
constructor
A new instance of RackContext.
- #parameters ⇒ Object
- #remote_ip ⇒ Object
- #request_method ⇒ Object
- #request_url ⇒ Object
- #session ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(env, request) ⇒ RackContext
Returns a new instance of RackContext.
4 5 6 7 |
# File 'lib/crashdesk-rack/rack_context.rb', line 4 def initialize(env, request) @env = env @request = request end |
Instance Method Details
#framework ⇒ Object
20 21 22 |
# File 'lib/crashdesk-rack/rack_context.rb', line 20 def framework "rack" end |
#framework_version ⇒ Object
24 25 26 |
# File 'lib/crashdesk-rack/rack_context.rb', line 24 def framework_version Rack.version # eq Rack::VERSION.join('.') end |
#headers ⇒ Object
44 45 46 |
# File 'lib/crashdesk-rack/rack_context.rb', line 44 def headers extract_http_headers(@env) end |
#parameters ⇒ Object
32 33 34 |
# File 'lib/crashdesk-rack/rack_context.rb', line 32 def parameters @request.params end |
#remote_ip ⇒ Object
40 41 42 |
# File 'lib/crashdesk-rack/rack_context.rb', line 40 def remote_ip @request.ip end |
#request_method ⇒ Object
36 37 38 |
# File 'lib/crashdesk-rack/rack_context.rb', line 36 def request_method @request.request_method.to_s end |
#request_url ⇒ Object
28 29 30 |
# File 'lib/crashdesk-rack/rack_context.rb', line 28 def request_url "#{@request.url}" end |
#session ⇒ Object
48 49 50 |
# File 'lib/crashdesk-rack/rack_context.rb', line 48 def session extract_session(@request) end |
#to_hash ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/crashdesk-rack/rack_context.rb', line 9 def to_hash { 'url' => request_url, 'parameters' => parameters, 'request_method' => request_method, 'remote_ip' => remote_ip, 'headers' => headers, 'session' => session, } end |