Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add Rack::Printout and myself as author

  • Loading branch information...
commit d5184f79962ccf71be66c33196aee1eaaa2ea89a 1 parent 759ab41
@JordiPolo JordiPolo authored
View
1  AUTHORS
@@ -24,3 +24,4 @@ TJ Holowaychuk <tj@vision-media.ca>
anupom syam <anupom.syam@gmail.com>
ichverstehe <ichverstehe@gmail.com>
kubicek <jiri@kubicek.cz>
+Jordi Polo <mumismo@gmail.com>
View
1  README.rdoc
@@ -48,6 +48,7 @@ interface:
* Rack::ResponseHeaders - Manipulates response headers object at runtime
* Rack::SimpleEndpoint - Creates simple endpoints with routing rules, similar to Sinatra actions
* Rack::TryStatic - Tries to match request to a static file
+* Rack::Printout - Prints the environment and the response per request
=== Use
View
1  lib/rack/contrib.rb
@@ -37,4 +37,5 @@ def self.release
autoload :RelativeRedirect, "rack/contrib/relative_redirect"
autoload :StaticCache, "rack/contrib/static_cache"
autoload :TryStatic, "rack/contrib/try_static"
+ autoload :Printout, "rack/contrib/printout"
end
View
25 lib/rack/contrib/printout.rb
@@ -0,0 +1,25 @@
+module Rack
+ #prints the environment and request for simple debugging
+ class Printout
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ # See http://rack.rubyforge.org/doc/SPEC.html for details
+ puts "**********\n Environment\n **************"
+ puts env.inspect
+
+ puts "**********\n Response\n **************"
+ response = @app.call(env)
+ puts response.inspect
+
+ puts "**********\n Response contents\n **************"
+ response[2].each do |chunk|
+ puts chunk
+ end
+ puts "\n \n"
+ return response
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.