Class: Kybus::Server::RequestResponse
- Inherits:
-
Object
- Object
- Kybus::Server::RequestResponse
- Defined in:
- lib/kybus/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.
12 13 14 15 16 |
# File 'lib/kybus/server/request_response.rb', line 12 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/kybus/server/request_response.rb', line 9 def exception @exception end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/kybus/server/request_response.rb', line 10 def params @params end |
#result ⇒ Object
Returns the value of attribute result.
9 10 11 |
# File 'lib/kybus/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/kybus/server/request_response.rb', line 9 def @start_timestamp end |
Instance Method Details
#code ⇒ Object
22 23 24 |
# File 'lib/kybus/server/request_response.rb', line 22 def code @exception.code end |
#data ⇒ Object
18 19 20 |
# File 'lib/kybus/server/request_response.rb', line 18 def data @exception.data end |
#ip ⇒ Object
30 31 32 |
# File 'lib/kybus/server/request_response.rb', line 30 def ip @request.ip end |
#message ⇒ Object
34 35 36 |
# File 'lib/kybus/server/request_response.rb', line 34 def @exception. end |
#path ⇒ Object
38 39 40 |
# File 'lib/kybus/server/request_response.rb', line 38 def path @request.env['PATH_INFO'] end |
#verb ⇒ Object
26 27 28 |
# File 'lib/kybus/server/request_response.rb', line 26 def verb @request.request_method end |