Class: Ant::Server::RequestResponse

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

Instance Method Summary collapse

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

#exceptionObject

Returns the value of attribute exception.



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

def exception
  @exception
end

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

#resultObject

Returns the value of attribute result.



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

def result
  @result
end

#start_timestampObject

Returns the value of attribute start_timestamp.



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

def start_timestamp
  @start_timestamp
end

Instance Method Details

#codeObject



21
22
23
# File 'lib/ant/server/request_response.rb', line 21

def code
  @exception.code
end

#dataObject



17
18
19
# File 'lib/ant/server/request_response.rb', line 17

def data
  @exception.data
end

#ipObject



29
30
31
# File 'lib/ant/server/request_response.rb', line 29

def ip
  @request.ip
end

#messageObject



33
34
35
# File 'lib/ant/server/request_response.rb', line 33

def message
  @exception.message
end

#pathObject



37
38
39
# File 'lib/ant/server/request_response.rb', line 37

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

#verbObject



25
26
27
# File 'lib/ant/server/request_response.rb', line 25

def verb
  @request.request_method
end