Module: Happy::Controller::Rackable

Extended by:
ActiveSupport::Concern
Included in:
Happy::Controller
Defined in:
lib/happy/controller/rackable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#handle_requestObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/happy/controller/rackable.rb', line 6

def handle_request
  r = catch :done do
    serve!(route) or raise Errors::NotFound
  end

  r ||response

rescue Errors::NotFound => e
  html = Errors.html e, self,
    :title => "Path not found",
    :message => '',
    :friendly_message => "You performed a <strong>#{request.request_method}</strong> request on <strong>#{request.path}</strong>, but your application did not know how to handle this request."
  [404, {'Content-type' => 'text/html'}, [html]]

rescue ::Exception => e
  html = Errors.html e, self
  [500, {'Content-type' => 'text/html'}, [html]]
end