lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.2.26 vs lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.2.27
- old
+ new
@@ -1,11 +1,11 @@
require_relative 'exchange_handler'
require_relative 'rest_parameters'
require_relative 'rest_parameters_defaults'
require_relative 'rest_exchanger_factory'
require_relative '../core_ext/hash'
-require_relative '../not_found_errors'
+require_relative '../errors'
require_relative 'handler_accessors'
require_relative '../interpreter'
require_relative 'response_extractor'
require_relative 'request/rest_request'
require 'json'
@@ -70,10 +70,15 @@
# Use q for query parameters. Nested :params is ugly, long and unclear
request_parameters[:params][:params] = request_parameters[:q] if request_parameters[:q]
request_parameters
end
+ # Override this with 'after_response' within class definition to perform an action
+ # after response is retrieved
+ # @param [RestClient::Response] _response Response to interpret to perform after block
+ def after_response(_response, _self) ; end
+
# Used in together with Exchange request that passes such override parameters
# @param [Hash] override_parameters Params to characterize REST request
# @option override_parameters [Hash] :params Extra parameters (E.g. headers)
# @option override_parameters [String] suburl URL appended to base_url of class
# @option override_parameters [Hash] :q Query for REST
@@ -101,9 +106,10 @@
end
rescue RestClient::ExceptionWithResponse => e
response = e.response
end
Soaspec::SpecLogger.info(["response_headers: #{response.headers}", "response_body: #{response}"])
+ after_response(response, self)
response
end
# Add values to here when extending this class to have default REST options.
# See rest client resource at https://github.com/rest-client/rest-client for details