Method: Grape::Middleware::Base#call!

Defined in:
lib/grape/middleware/base.rb

#call!(env) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/grape/middleware/base.rb', line 22

def call!(env)
  @env = env
  before
  begin
    @app_response = @app.call(@env)
  ensure
    begin
      after_response = after
    rescue StandardError => e
      warn "caught error of type #{e.class} in after callback inside #{self.class.name} : #{e.message}"
      raise e
    end
  end

  response = after_response || @app_response
  merge_headers response
  response
end