Class: Datadog::AppSec::Contrib::Rack::Gateway::Request
Overview
Gateway Request argument. Normalized extration of data from Rack::Request
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(env) ⇒ Request
Returns a new instance of Request.
16
17
18
19
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 16
def initialize(env)
super()
@env = env
end
|
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
14
15
16
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 14
def env
@env
end
|
Instance Method Details
#body ⇒ Object
52
53
54
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 52
def body
request.body.read.tap { request.body.rewind }
end
|
#cookies ⇒ Object
68
69
70
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 68
def cookies
request.cookies
end
|
84
85
86
87
88
89
90
91
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 84
def form_hash
request.POST if request.form_data?
env['rack.request.form_hash']
end
|
#fullpath ⇒ Object
60
61
62
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 60
def fullpath
request.fullpath
end
|
42
43
44
45
46
47
48
49
50
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 42
def
result = request.env.each_with_object({}) do |(k, v), h|
h[k.gsub(/^HTTP_/, '').downcase!.tr('_', '-')] = v if k =~ /^HTTP_/
end
result['content-type'] = request.content_type if request.content_type
result['content-length'] = request.content_length if request.content_length
result
end
|
#host ⇒ Object
72
73
74
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 72
def host
request.host
end
|
#method ⇒ Object
38
39
40
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 38
def method
request.request_method
end
|
#path ⇒ Object
64
65
66
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 64
def path
request.path
end
|
#query ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 25
def query
request.query_string.split('&').each.with_object({}) do |e, hash|
k, v = e.split('=').map { |s| CGI.unescape(s) }
hash[k] ||= []
hash[k] << v
end
end
|
#remote_addr ⇒ Object
80
81
82
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 80
def remote_addr
env['REMOTE_ADDR']
end
|
#request ⇒ Object
21
22
23
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 21
def request
@request ||= ::Rack::Request.new(env)
end
|
#url ⇒ Object
56
57
58
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 56
def url
request.url
end
|
#user_agent ⇒ Object
76
77
78
|
# File 'lib/datadog/appsec/contrib/rack/gateway/request.rb', line 76
def user_agent
request.user_agent
end
|