Sha256: 2f9b315fcb756461bbbc32ace7de65086df8cdaac9aa4c75a9ff480cf3ecbb81

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

module Happy
  class Controller
    module Rackable
      extend ActiveSupport::Concern

      def handle_request
        catch :done do
          serve!(perform) or raise Errors::NotFound
        end

        response
      rescue Errors::NotFound => e
        html = Errors.html e, env,
          :title => "Path not found",
          :message => '',
          :friendly_message => "You performed a <strong>#{context.request.request_method}</strong> request on <strong>#{context.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, env
        [500, {'Content-type' => 'text/html'}, [html]]
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
happy-0.1.0.pre19 lib/happy/controller/rackable.rb