[web-devel] WAI routing?
Stephen Paul Weber
singpolyma at singpolyma.net
Sun Mar 18 18:12:27 CET 2012
-----BEGIN PGP SIGNED MESSAGE-----
Somebody claiming to be Michael Snoyman wrote:
>On Sun, Mar 18, 2012 at 2:21 PM, Gregory Collins
>>> you might be interested in looking at the routing code in scotty,
>>> which has some extra features.
>> Routing there is also O(n) in the number of handlers
>The code at play for Yesod is in the Yesod.Routes.Dispatch module.
>The source is highly commented Literate Haskell, which goes into
>details of our algorithm, which takes advantage of vectors for an
>initial O(1) whittling down of possible routes, followed by a series
>of Map lookups, and finally a linear traversal of the remaining
>routes to address parsing of dynamic pieces. If you avoid overlapping
>routes (highly recommended), then the last stage will always have
>either 0 or 1 matches.
Hmm, this also looks interesting. Though it's more of a backend algorithm
for a router than a router itself (which is fine). It might be interesting
to patch support into Scotty (definitely possible).
I wonder what the overhead is (ie: approximately how many routes one needs
before the fancy algorithm is faster).
Stephen Paul Weber, @singpolyma
See <http://singpolyma.net> for how I prefer to be contacted
edition right joseph
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the web-devel