Sha256: 80d4f6e19096d18623b4cf8f50f4b86d811908eecaf27a8be6f540a88bfaf424
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require "panda/version" require "panda/utils" require "panda/record/base" require "panda/routing/router" require "panda/routing/mapper" require "panda/base_controller" require "panda/dependencies" module Panda class Application attr_reader :routes def initialize @routes = Routing::Router.new end def call(env) return [500, {}, []] if env["PATH_INFO"] == "/favicon.ico" request = Rack::Request.new(env) handler = mapper.perform(request) if handler call_controller_action(request, handler[:target]) else process_invalid_request(request) end end private def call_controller_action(request, target) controller = Object.const_get("#{target[0]}Controller") controller.new(request).dispatch(target[1]) end def process_invalid_request(request) [ 404, {}, ["Oops! No route for #{request.request_method} #{request.path_info}"] ] end def mapper @mapper ||= Routing::Mapper.new(routes.endpoints) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
panda_frwk-0.1.0 | lib/panda.rb |