Class: Podio::Middleware::ResponseRecorder

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/podio/middleware/response_recorder.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



6
7
8
9
10
11
# File 'lib/podio/middleware/response_recorder.rb', line 6

def on_complete(env)
  response = "['#{Faraday::Utils.normalize_path(env[:url])}', :#{env[:method]}, #{env[:status]}, #{env[:response_headers]}, '#{env[:body]}']"

  filename = Digest::MD5.hexdigest(env[:url].request_uri)
  ::File.open("#{filename}.rack", 'w') { |f| f.write(response) }
end