Class: RailsHush::HushOne

Inherits:
Object
  • Object
show all
Includes:
ShowExceptions, SimpleRenderer
Defined in:
lib/rails_hush/middleware/hush_one.rb

Constant Summary

Constants included from ShowExceptions

ShowExceptions::SHOWABLE

Instance Method Summary collapse

Methods included from SimpleRenderer

#default_renderer, #log_request, #render

Methods included from ShowExceptions

#show_exceptions?

Constructor Details

#initialize(app, renderer = nil) ⇒ HushOne

Returns a new instance of HushOne.



6
7
8
9
# File 'lib/rails_hush/middleware/hush_one.rb', line 6

def initialize(app, renderer=nil)
  @app = app
  @renderer ||= Rails.application.config.rails_hush.renderer || method(:default_renderer)
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rails_hush/middleware/hush_one.rb', line 11

def call(env)
  request = ActionDispatch::Request.new env
  if show_exceptions?(request) && !request.get_header("action_dispatch.show_detailed_exceptions")
    begin
      @app.call(env)
    rescue ActionController::UnknownHttpMethod
      render 405, request, 'Unrecognized HTTP method'
    end
  else
    @app.call(env)
  end
end