Class: Kybus::Server::RequestResponse

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#exceptionObject

Returns the value of attribute exception.



9
10
11
# File 'lib/kybus/server/request_response.rb', line 9

def exception
  @exception
end

#paramsObject (readonly)

Returns the value of attribute params.



10
11
12
# File 'lib/kybus/server/request_response.rb', line 10

def params
  @params
end

#resultObject

Returns the value of attribute result.



9
10
11
# File 'lib/kybus/server/request_response.rb', line 9

def result
  @result
end

#start_timestampObject

Returns the value of attribute start_timestamp.



9
10
11
# File 'lib/kybus/server/request_response.rb', line 9

def start_timestamp
  @start_timestamp
end

Instance Method Details

#codeObject



22
23
24
# File 'lib/kybus/server/request_response.rb', line 22

def code
  @exception.code
end

#dataObject



18
19
20
# File 'lib/kybus/server/request_response.rb', line 18

def data
  @exception.data
end

#ipObject



30
31
32
# File 'lib/kybus/server/request_response.rb', line 30

def ip
  @request.ip
end

#messageObject



34
35
36
# File 'lib/kybus/server/request_response.rb', line 34

def message
  @exception.message
end

#pathObject



38
39
40
# File 'lib/kybus/server/request_response.rb', line 38

def path
  @request.env['PATH_INFO']
end

#verbObject



26
27
28
# File 'lib/kybus/server/request_response.rb', line 26

def verb
  @request.request_method
end