Object
Register a handler object at a particular URI. The handler can be whatever you want, including an array. It's up to you what to do with it.
Registering a handler is not necessarily threadsafe, so be careful if you go mucking around once the server is running.
# File lib/mongrel/uri_classifier.rb, line 28 def register(uri, handler) raise RegistrationError, "#{uri.inspect} is already registered" if @handler_map[uri] raise RegistrationError, "URI is empty" if !uri or uri.empty? raise RegistrationError, "URI must begin with a \"#{Const::SLASH}\"" unless uri[0..0] == Const::SLASH @handler_map[uri.dup] = handler rebuild end
Resolve a request URI by finding the best partial match in the registered handler URIs.
# File lib/mongrel/uri_classifier.rb, line 46 def resolve(request_uri) if @root_handler # Optimization for the pathological case of only one handler on "/"; e.g. Rails [Const::SLASH, request_uri, @root_handler] elsif match = @matcher.match(request_uri) uri = match.to_s # A root mounted ("/") handler must resolve such that path info matches the original URI. [uri, (uri == Const::SLASH ? request_uri : match.post_match), @handler_map[uri]] else [nil, nil, nil] end end
Generated with the Darkfish Rdoc Generator 2.