public
Last active

  • Download Gist
non_awkward_rack_api.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
class ResponseTimer
def call(env, &block)
now = Time.now
@app.call(env, &block)
$stderr.puts({'X-Response-Took' => (Time.now - now)})
end
end
 
class FakeRack
def serve(application)
application.call({}) do |status, headers, body|
p :status => status
p :headers => headers
body.each do |string|
p string
end
body.close if body.respond_to?(:close)
end
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.