Class: CrashdeskRack::RackContext

Inherits:
Crashdesk::ContextBase
  • Object
show all
Defined in:
lib/crashdesk-rack/rack_context.rb

Instance Method Summary collapse

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

#frameworkObject



20
21
22
# File 'lib/crashdesk-rack/rack_context.rb', line 20

def framework
  "rack"
end

#framework_versionObject



24
25
26
# File 'lib/crashdesk-rack/rack_context.rb', line 24

def framework_version
  Rack.version # eq Rack::VERSION.join('.')
end

#headersObject



44
45
46
# File 'lib/crashdesk-rack/rack_context.rb', line 44

def headers
  extract_http_headers(@env)
end

#parametersObject



32
33
34
# File 'lib/crashdesk-rack/rack_context.rb', line 32

def parameters
  @request.params
end

#remote_ipObject



40
41
42
# File 'lib/crashdesk-rack/rack_context.rb', line 40

def remote_ip
  @request.ip
end

#request_methodObject



36
37
38
# File 'lib/crashdesk-rack/rack_context.rb', line 36

def request_method
  @request.request_method.to_s
end

#request_urlObject



28
29
30
# File 'lib/crashdesk-rack/rack_context.rb', line 28

def request_url
  "#{@request.url}"
end

#sessionObject



48
49
50
# File 'lib/crashdesk-rack/rack_context.rb', line 48

def session
  extract_session(@request)
end

#to_hashObject



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