Class: Middleware
- Inherits:
-
Object
- Object
- Middleware
- Defined in:
- lib/bard_staging_banner/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
2 3 4 |
# File 'lib/bard_staging_banner/middleware.rb', line 2 def initialize app @app = app end |
Instance Method Details
#call(env) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/bard_staging_banner/middleware.rb', line 6 def call env @status, @headers, @body = @app.call(env) return [@status, @headers, @body] unless html? response = Rack::Response.new([], @status, @headers) @body.each do |fragment| response.write inject(fragment) end @body.close if @body.respond_to?(:close) response.finish end |