Sha256: 55541bf4cb94aa9c6cc35d0bbf3b9c72bc943343c54c527efe75260c0f041017
Contents?: true
Size: 859 Bytes
Versions: 9
Compression:
Stored size: 859 Bytes
Contents
module ActiveTracker class OutputCapturer def initialize(app) @app = app end def call(env) start_time = Time.current status, headers, response = @app.call(env) [status, headers, response] ensure capture(response) duration = (Time.current.to_f - start_time.to_f) * 1000 ActiveTracker::Plugin::Request.record_duration(duration) end def capture(response) body = response.body rescue nil unless body.is_a?(String) body = body.to_a rescue [body.body] rescue "No body given" end if body.respond_to?(:each) output = [] body.each do |line| output << line end output = output.join("\n") else output = body.to_s end ActiveTracker::Plugin::Request.output_capture(output) end end end
Version data entries
9 entries across 9 versions & 1 rubygems