Module: Happy::Controller::Rackable

Included in:
Happy::Controller
Defined in:
lib/happy/controller/rackable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


4
5
6
# File 'lib/happy/controller/rackable.rb', line 4

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#handle_requestObject


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

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