Class: RightDevelop::Testing::Client::Rest::Request::Record
- Inherits:
-
Base
- Object
- RestClient::Request
- Base
- RightDevelop::Testing::Client::Rest::Request::Record
- Defined in:
- lib/right_develop/testing/clients/rest/requests/record.rb
Overview
Provides a middle-ware layer that intercepts response by overriding the logging mechanism built into rest-client Request. Request supports ‘before’ hooks (for request) but not ‘after’ hooks (for response) so logging is all we have.
Defined Under Namespace
Classes: TimeoutNetHttpResponse
Constant Summary
Constants inherited from Base
Base::METADATA_CLASS, Base::MUTEX
Instance Attribute Summary
Attributes inherited from Base
#fixtures_dir, #logger, #request_metadata, #request_timestamp, #response_metadata, #response_timestamp, #route_data, #route_path, #state_file_path
Instance Method Summary collapse
- #handle_timeout ⇒ Object
-
#log_request ⇒ Object
Overrides log_request for basic logging.
-
#log_response(response) ⇒ Object
Overrides log_response to capture both request and response.
-
#transmit(uri, req, payload, &block) ⇒ Object
Overrides transmit to catch halt thrown by log_request.
Methods inherited from Base
#forget_outstanding_request, #initialize
Constructor Details
This class inherits a constructor from RightDevelop::Testing::Client::Rest::Request::Base
Instance Method Details
#handle_timeout ⇒ Object
105 106 107 108 109 110 |
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 105 def handle_timeout super response = TimeoutNetHttpResponse.new with_state_lock { |state| record_response(state, response) } response end |
#log_request ⇒ Object
Overrides log_request for basic logging.
88 89 90 91 |
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 88 def log_request logger.debug("proxied_url = #{@url.inspect}") super end |
#log_response(response) ⇒ Object
Overrides log_response to capture both request and response.
98 99 100 101 102 |
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 98 def log_response(response) result = super with_state_lock { |state| record_response(state, response) } result end |
#transmit(uri, req, payload, &block) ⇒ Object
Overrides transmit to catch halt thrown by log_request.
73 74 75 76 77 78 79 80 81 |
# File 'lib/right_develop/testing/clients/rest/requests/record.rb', line 73 def transmit(uri, req, payload, &block) super rescue ::Interrupt if @request_timestamp logger.warn('Interrupted with at least one request outstanding; will record a timeout response.') handle_timeout end raise end |