Class: PumaAfterReply::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/puma_after_reply/middleware.rb

Overview

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • app (?)

Since:

  • 0.1.0



11
12
13
# File 'lib/puma_after_reply/middleware.rb', line 11

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

PumaAfterReply.call integration to the puma’s ‘rack.after_reply` env variable that is used for the “after reply” hook inside the puma’s request dispatching.

Parameters:

  • env (?)

Returns:

  • (Array)

Since:

  • 0.1.0



23
24
25
26
27
28
29
30
31
# File 'lib/puma_after_reply/middleware.rb', line 23

def call(env)
  @app.call(env).tap do
    if env.key?('rack.after_reply')
      env['rack.after_reply'] << proc { PumaAfterReply.call }
    elsif PumaAfterReply::Config.run_anyway
      PumaAfterReply.call # NOTE: may be usefull for/from-inside test environments
    end
  end
end