Class: Rack::Headers::Print

Inherits:
Object
  • Object
show all
Defined in:
lib/rack_headers/print.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) {|_self| ... } ⇒ Print

Returns a new instance of Print.

Yields:

  • (_self)

Yield Parameters:



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 ||= Rails.configuration.logger if defined?(Rails)
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
# File 'lib/rack_headers/print.rb', line 20

def call(env)
  output(request_headers, env)
  status, headers, response = @app.call(env)
  output(response_headers, headers)
  [status, headers, response]
end