diff options
Diffstat (limited to 'doc/rdoc/classes/Mongrel/URIClassifier.src/M000013.html')
-rw-r--r-- | doc/rdoc/classes/Mongrel/URIClassifier.src/M000013.html | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/doc/rdoc/classes/Mongrel/URIClassifier.src/M000013.html b/doc/rdoc/classes/Mongrel/URIClassifier.src/M000013.html new file mode 100644 index 0000000..a843bc8 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/URIClassifier.src/M000013.html @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>new (Mongrel::URIClassifier)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * URIClassifier.new -> URIClassifier + * + * Initializes a new URIClassifier object that you can use to associate URI sequences + * with objects. You can actually use it with any string sequence and any objects, + * but it's mostly used with URIs. + * + * It uses TST from http://www.octavian.org/cs/software.html to build an ternary search + * trie to hold all of the URIs. It uses this to do an initial search for the a URI + * prefix, and then to break the URI into SCRIPT_NAME and PATH_INFO portions. It actually + * will do two searches most of the time in order to find the right handler for the + * registered prefix portion. + * + * Here's how it all works. Let's say you register "/blog" with a BlogHandler. Great. + * Now, someone goes to "/blog/zedsucks/ass". You want SCRIPT_NAME to be "/blog" and + * PATH_INFO to be "/zedsucks/ass". URIClassifier first does a TST search and comes + * up with a failure, but knows that the failure ended at the "/blog" part. So, that's + * the SCRIPT_NAME. It then tries a second search for just "/blog". If that comes back + * good then it sets the rest ("/zedsucks/ass") to the PATH_INFO and returns the BlogHandler. + * + * The optimal approach would be to not do the search twice, but the TST lib doesn't + * really support returning prefixes. Might not be hard to add later. + * + * The key though is that it will try to match the *longest* match it can. If you + * also register "/blog/zed" then the above URI will give SCRIPT_NAME="/blog/zed", + * PATH_INFO="sucks/ass". Probably not what you want, so your handler will need to + * do the 404 thing. + * + * Take a look at the postamble of example/tepee.rb to see how this is handled for + * Camping. + */ +VALUE URIClassifier_init(VALUE self) +{ + VALUE hash; + + // we create an internal hash to protect stuff from the GC + hash = rb_hash_new(); + rb_iv_set(self, "handler_map", hash); +}</pre> +</body> +</html>
\ No newline at end of file |