Class: Eyeloupe::Processors::OutRequest
- Inherits:
-
Object
- Object
- Eyeloupe::Processors::OutRequest
- Includes:
- Singleton
- Defined in:
- lib/eyeloupe/processors/out_request.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #init(request, body) ⇒ Object
-
#initialize ⇒ OutRequest
constructor
A new instance of OutRequest.
-
#process(response, ex) ⇒ Net::HTTPResponse
The response object.
Constructor Details
#initialize ⇒ OutRequest
Returns a new instance of OutRequest.
17 18 19 20 21 |
# File 'lib/eyeloupe/processors/out_request.rb', line 17 def initialize @request = nil @body = "" @started_at = nil end |
Instance Attribute Details
#body ⇒ String
12 13 14 |
# File 'lib/eyeloupe/processors/out_request.rb', line 12 def body @body end |
#request ⇒ Net::HTTPRequest?
9 10 11 |
# File 'lib/eyeloupe/processors/out_request.rb', line 9 def request @request end |
#started_at ⇒ Time?
15 16 17 |
# File 'lib/eyeloupe/processors/out_request.rb', line 15 def started_at @started_at end |
Instance Method Details
#init(request, body) ⇒ Object
25 26 27 28 29 |
# File 'lib/eyeloupe/processors/out_request.rb', line 25 def init(request, body) @request = request @body = body @started_at = Time.now end |
#process(response, ex) ⇒ Net::HTTPResponse
Returns The response object.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/eyeloupe/processors/out_request.rb', line 34 def process(response, ex) req = Eyeloupe::OutRequest.create( verb: @request.method, hostname: @request['host'], path: @request.path, status: response.code, format: response.content_type, duration: (Time.now - @started_at) * 1000, payload: @request.body, req_headers: (get_headers(@request) || {}).to_json, res_headers: (get_headers(response) || {}).to_json, response: response.body, ) ex.update(out_request_id: req.id) if ex.present? && ex.out_request_id.blank? response end |