Class: TemplateStreaming::ErrorRecovery::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/template_streaming/error_recovery.rb

Defined Under Namespace

Classes: BodyProxy

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



7
8
9
# File 'lib/template_streaming/error_recovery.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/template_streaming/error_recovery.rb', line 11

def call(env)
  response = *@app.call(env)
  if env[TemplateStreaming::STREAMING_KEY]
    response[2] = BodyProxy.new(env, response[2])
    response
  else
    response
  end
end