Class: Rack::Headers::Print
- Inherits:
-
Object
- Object
- Rack::Headers::Print
- Defined in:
- lib/rack_headers/print.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#request_headers ⇒ Object
Returns the value of attribute request_headers.
-
#response_headers ⇒ Object
Returns the value of attribute response_headers.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) {|_self| ... } ⇒ Print
constructor
A new instance of Print.
Constructor Details
#initialize(app) {|_self| ... } ⇒ Print
Returns a new instance of Print.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rack_headers/print.rb', line 9 def initialize(app) @app = app yield self if block_given? # Defaults self.request_headers ||= ['If-Modified-Since'] self.response_headers ||= ['Last-Modified'] self.logger ||= defined?(RAILS_DEFAULT_LOGGER) ? RAILS_DEFAULT_LOGGER : Logger.new(STDOUT) end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/rack_headers/print.rb', line 7 def logger @logger end |
#request_headers ⇒ Object
Returns the value of attribute request_headers.
5 6 7 |
# File 'lib/rack_headers/print.rb', line 5 def request_headers @request_headers end |
#response_headers ⇒ Object
Returns the value of attribute response_headers.
6 7 8 |
# File 'lib/rack_headers/print.rb', line 6 def response_headers @response_headers end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/rack_headers/print.rb', line 20 def call(env) output(request_headers, env, '==> Request Headers: ') status, headers, response = @app.call(env) output(response_headers, headers, '<== Response Headers: ') logger.info("\n\n") [status, headers, response] end |