Created
August 10, 2011 08:37
-
-
Save jergason/1136379 to your computer and use it in GitHub Desktop.
Checking size of each request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#in top of your app.rb file | |
require 'sinatra' | |
require 'response_size' | |
use Rack::ResponseSize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
# Save size of response | |
class ResponseSize | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
response = @app.call(env) | |
File.open("size.log", "a") do |f| | |
# super ghetto | |
f.write "Response Size: #{Marshal.dump(response).length}" | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment