Class: Depthcharge::Middleware
- Inherits:
-
Object
- Object
- Depthcharge::Middleware
- Defined in:
- lib/depthcharge/middleware.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, *outputs) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, *outputs) ⇒ Middleware
Returns a new instance of Middleware.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/depthcharge/middleware.rb', line 6 def initialize(app, *outputs) @app = app @outputs = outputs.flatten.map do |output| if output.is_a?(String) || output.is_a?(Pathname) File.open(output, "w") else output end end end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
4 5 6 |
# File 'lib/depthcharge/middleware.rb', line 4 def app @app end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
4 5 6 |
# File 'lib/depthcharge/middleware.rb', line 4 def outputs @outputs end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 |
# File 'lib/depthcharge/middleware.rb', line 17 def call(env) status, headers, body = @app.call(env) RequestLogger.new(env, status, headers, body).log(outputs) [status, headers, body] end |