Sha256: 8055911a45a891ac548178b19af25733dfbdae86de76ac1bc92c9978c468b235

Contents?: true

Size: 874 Bytes

Versions: 7

Compression:

Stored size: 874 Bytes

Contents

module Happy
  class Controller
    module Rackable
      extend ActiveSupport::Concern

      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

      module ClassMethods
        def call(env)
          new(env).handle_request.to_a
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
happy-0.1.0 lib/happy/controller/rackable.rb
happy-0.1.0.pre28 lib/happy/controller/rackable.rb
happy-0.1.0.pre27 lib/happy/controller/rackable.rb
happy-0.1.0.pre25 lib/happy/controller/rackable.rb
happy-0.1.0.pre24 lib/happy/controller/rackable.rb
happy-0.1.0.pre23 lib/happy/controller/rackable.rb
happy-0.1.0.pre22 lib/happy/controller/rackable.rb