Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Printout contribution #30

Merged
merged 1 commit into from

2 participants

@JordiPolo

I was hunting down a problem with last-modified headers.
I ended up writing this rack to help me find out what was happening.

Please pull it if you think it may be useful

@rkh rkh merged commit 9c1c02a into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 5, 2011
  1. @JordiPolo
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.