Class: Datadog::AppSec::Contrib::Rails::Gateway::Request
- Inherits:
-
Instrumentation::Gateway::Argument
- Object
- Instrumentation::Gateway::Argument
- Datadog::AppSec::Contrib::Rails::Gateway::Request
- Defined in:
- lib/datadog/appsec/contrib/rails/gateway/request.rb
Overview
Gateway Request argument. Normalized extration of data from ActionDispatch::Request
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #env ⇒ Object
- #headers ⇒ Object
- #host ⇒ Object
-
#initialize(request) ⇒ Request
constructor
A new instance of Request.
- #parsed_body ⇒ Object
- #remote_addr ⇒ Object
- #route_params ⇒ Object
- #user_agent ⇒ Object
Constructor Details
#initialize(request) ⇒ Request
Returns a new instance of Request.
14 15 16 17 |
# File 'lib/datadog/appsec/contrib/rails/gateway/request.rb', line 14 def initialize(request) super() @request = request end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
12 13 14 |
# File 'lib/datadog/appsec/contrib/rails/gateway/request.rb', line 12 def request @request end |
Instance Method Details
#env ⇒ Object
19 20 21 |
# File 'lib/datadog/appsec/contrib/rails/gateway/request.rb', line 19 def env request.env end |
#headers ⇒ Object
23 24 25 |
# File 'lib/datadog/appsec/contrib/rails/gateway/request.rb', line 23 def headers request.headers end |
#host ⇒ Object
27 28 29 |
# File 'lib/datadog/appsec/contrib/rails/gateway/request.rb', line 27 def host request.host end |
#parsed_body ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/datadog/appsec/contrib/rails/gateway/request.rb', line 39 def parsed_body # force body parameter parsing, which is done lazily by Rails request.parameters # usually Hash<String,String> but can be a more complex # Hash<String,String||Array||Hash> when e.g coming from JSON or # with Rails advanced param square bracket parsing body = request.env['action_dispatch.request.request_parameters'] return if body.nil? body.reject do |k, _v| request.env['action_dispatch.request.path_parameters'].key?(k) end end |
#remote_addr ⇒ Object
35 36 37 |
# File 'lib/datadog/appsec/contrib/rails/gateway/request.rb', line 35 def remote_addr request.remote_addr end |
#route_params ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/datadog/appsec/contrib/rails/gateway/request.rb', line 55 def route_params excluded = [:controller, :action] request.env['action_dispatch.request.path_parameters'].reject do |k, _v| excluded.include?(k) end end |
#user_agent ⇒ Object
31 32 33 |
# File 'lib/datadog/appsec/contrib/rails/gateway/request.rb', line 31 def user_agent request.user_agent end |