Class: Ant::Server::RequestResponse
- Inherits:
-
Object
- Object
- Ant::Server::RequestResponse
- Defined in:
- lib/ant/server/request_response.rb
Overview
Wraps the request and the response into an object so it is easier to track monitoring logs and format the response after the endpoint was executed
Instance Attribute Summary collapse
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#result ⇒ Object
Returns the value of attribute result.
-
#start_timestamp ⇒ Object
Returns the value of attribute start_timestamp.
Instance Method Summary collapse
- #code ⇒ Object
- #data ⇒ Object
-
#initialize(request:, params:) ⇒ RequestResponse
constructor
A new instance of RequestResponse.
- #ip ⇒ Object
- #message ⇒ Object
- #path ⇒ Object
- #verb ⇒ Object
Constructor Details
#initialize(request:, params:) ⇒ RequestResponse
Returns a new instance of RequestResponse.
11 12 13 14 15 |
# File 'lib/ant/server/request_response.rb', line 11 def initialize(request:, params:) @request = request @params = params @start_timestamp = Time.now end |
Instance Attribute Details
#exception ⇒ Object
Returns the value of attribute exception.
9 10 11 |
# File 'lib/ant/server/request_response.rb', line 9 def exception @exception end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
9 10 11 |
# File 'lib/ant/server/request_response.rb', line 9 def params @params end |
#result ⇒ Object
Returns the value of attribute result.
9 10 11 |
# File 'lib/ant/server/request_response.rb', line 9 def result @result end |
#start_timestamp ⇒ Object
Returns the value of attribute start_timestamp.
9 10 11 |
# File 'lib/ant/server/request_response.rb', line 9 def @start_timestamp end |
Instance Method Details
#code ⇒ Object
21 22 23 |
# File 'lib/ant/server/request_response.rb', line 21 def code @exception.code end |
#data ⇒ Object
17 18 19 |
# File 'lib/ant/server/request_response.rb', line 17 def data @exception.data end |
#ip ⇒ Object
29 30 31 |
# File 'lib/ant/server/request_response.rb', line 29 def ip @request.ip end |
#message ⇒ Object
33 34 35 |
# File 'lib/ant/server/request_response.rb', line 33 def @exception. end |
#path ⇒ Object
37 38 39 |
# File 'lib/ant/server/request_response.rb', line 37 def path @request.env['PATH_INFO'] end |
#verb ⇒ Object
25 26 27 |
# File 'lib/ant/server/request_response.rb', line 25 def verb @request.request_method end |