Sha256: e9a95cdf0c2e72feab6f23b104795adb2a06aeb6d06bce5a86312f57b4293440

Contents?: true

Size: 869 Bytes

Versions: 2

Compression:

Stored size: 869 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
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
happy-0.1.0.pre21 lib/happy/controller/rackable.rb
happy-0.1.0.pre20 lib/happy/controller/rackable.rb