Class: FrontendRescue::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}, &block) ⇒ Middleware

Returns a new instance of Middleware.



5
6
7
8
9
# File 'lib/frontend_rescue/middleware.rb', line 5

def initialize(app, opts={}, &block)
  @app = app
  @opts = default_options.merge(opts)
  @block = block
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/frontend_rescue/middleware.rb', line 11

def call(env)
  if frontend_error_request?(env)
    handle_error Rack::Request.new(env)
  else
    @app.call(env)
  end
end