0
- %w(rubygems merb
/core_ext merb/router uri).each {|dep|require dep}
0
+ %w(rubygems merb
-core/core_ext merb-core/dispatch/router uri).each {|dep|require dep}
0
abort "Merb must be installed for Routing to function. Please install Merb."
0
@@ -59,43 +59,44 @@ module Halcyon
0
# http://merbivore.com/
0
class Router < Merb::Router
0
- # Retrieves the last value from the +route+ call in Halcyon::Server::Base
0
- # and, if it's a Hash, sets it to +@@default_route+ to designate the
0
- # failover route. If +route+ is not a Hash, though, the internal default
0
- # should be used instead (as the last returned value is probably a Route
0
- # object returned by the +r.match().to()+ call).
0
- # Used exclusively internally.
0
- def self.default_to route
0
- @@default_route = route.is_a?(Hash) ? route : {:action => 'not_found'}
0
- # Called internally by the Halcyon::Server::Base#call method to match
0
- # the current request against the currently defined routes. Returns the
0
- # params list defined in the +to+ routing definition, opting for the
0
- # default route if no match is made.
0
- # pull out the path requested (WEBrick keeps the host and port and protocol in REQUEST_URI)
0
- # PATH_INFO is failover if REQUEST_URI is blank (like what Rack::MockRequest does)
0
- uri = URI.parse(env['REQUEST_URI'] || env['PATH_INFO']).path
0
- path = (uri ? uri.split('?').first : '').sub(/\/+/, '/')
0
- path = path[0..-2] if (path[-1] == ?/) && path.size > 1
0
- req = Struct.new(:path, :method).new(path, env['REQUEST_METHOD'].downcase.to_sym)
0
- route = self.match(req, {})
0
+ # Retrieves the last value from the +route+ call in Halcyon::Server::Base
0
+ # and, if it's a Hash, sets it to +@@default_route+ to designate the
0
+ # failover route. If +route+ is not a Hash, though, the internal default
0
+ # should be used instead (as the last returned value is probably a Route
0
+ # object returned by the +r.match().to()+ call).
0
+ # Used exclusively internally.
0
+ @@default_route = route.is_a?(Hash) ? route : {:action => 'not_found'}
0
- # make sure a route is returned even if no match is found
0
- env['halcyon.logger'].debug "No route found. Using default." if env['halcyon.logger'].is_a? Logger
0
- # params (including action and module if set) for the matching route
0
+ # Called internally by the Halcyon::Server::Base#call method to match
0
+ # the current request against the currently defined routes. Returns the
0
+ # params list defined in the +to+ routing definition, opting for the
0
+ # default route if no match is made.
0
+ req = Struct.new(:path, :method, :params).new(request.path_info, request.request_method.downcase.to_sym, request.params)
0
+ route = self.match(req)
0
+ # make sure a route is returned even if no match is found
0
+ self.logger.debug "No route found. Using default."
0
+ # params (including action and module if set) for the matching route
Comments
No one has commented yet.