Skip to content

Instantly share code, notes, and snippets.

@benzittlau
Created November 13, 2015 16:20
Show Gist options
  • Save benzittlau/4895da8c7be5a95a4949 to your computer and use it in GitHub Desktop.
Save benzittlau/4895da8c7be5a95a4949 to your computer and use it in GitHub Desktop.
module Net
class HTTP
def request_with_monitor(request, body = nil, &block)
# Continue with the original request
response = request_without_monitor(request, body, &block)
begin
::NetNanny::HttpNetMonitor.output_request_debug_info(self, request)
if ::NetNanny::Registry.instance.registered_address?(self.address)
::NetNanny::Registry.instance.respond_to(self, request, response)
end
::NetNanny::Registry.instance.respond_for_all_urls(self, request, response)
::NetNanny::HttpNetMonitor.output_response_debug_info(self, request, response)
rescue => ex
Rails.logger.warn "Error processing request monitor - #{ex.message}"
end
response
end
alias_method :request_without_monitor, :request
alias_method :request, :request_with_monitor
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment