lib/ramaze/dispatcher.rb in ramaze-0.3.5 vs lib/ramaze/dispatcher.rb in ramaze-0.3.9

- old
+ new

@@ -1,12 +1,9 @@ # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com # All files in this distribution are subject to the terms of the Ruby license. -require 'timeout' - require 'ramaze/error' -require 'ramaze/adapter' require 'ramaze/tool/mime' require 'ramaze/dispatcher/action' require 'ramaze/dispatcher/error' require 'ramaze/dispatcher/file' @@ -29,13 +26,11 @@ include Trinity # Entry point for Adapter#respond, takes a Rack::Request and # Rack::Response, sets up the environment and the goes on to dispatch # for the given path from rack_request. - def handle rack_request, rack_response - setup_environment(rack_request, rack_response) - + def handle path = request.path_info.squeeze('/') case path when *Global.ignore unless ::File.exist?(Dispatcher::File.resolve_path(path)) @@ -121,31 +116,9 @@ meta = { :path => path, :controller => Thread.current[:controller] } Dispatcher::Error.process(result, meta) - end - - # finalizes the session and assigns the key to the response via - # set_cookie. - - def set_cookie - session.finalize - hash = {:value => session.session_id}.merge(Session::COOKIE) - response.set_cookie(Session::SESSION_KEY, hash) - end - - # Setup the Trinity (Request, Response, Session) and store them as - # thread-variables in Thread.current - # Thread.current[:request] == Request.current - # Thread.current[:response] == Response.current - # Thread.current[:session] == Session.current - - def setup_environment rack_request, rack_response - this = Thread.current - this[:request] = rack_request - this[:session] = Session.new(request) if Global.sessions - this[:response] = rack_response end end end end