[web-devel] Overlapping in routes

Alexey Khudyakov alexey.skladnoy at gmail.com
Thu Jun 23 22:42:05 CEST 2011


Hello!

I thought about routes and overlapping. I'm not talking about actual 
implementation but rather trying to construct simple model.

First of all what is overlapping in routes? Simplest definition is
routes do not overlap if any URL match to one route or do not match.
Bad thing it couldn't be checked statically. Using for example Eric's
routes.

 > /add
 > /#Int

This routes do not overlap. We can make this conclusion because we know 
SinglePiece instance of Int. Overlapping checker could not have this 
information.

Better definition is. Routes do not overlap is any URL could be mapped 
to one or zero routes assuming that SinglePiece match any piece.




Now lets consider case of unlimited overlapping. Routes are matched from
top to bottom. First route to match is selected. If singlePiece or
multiPiece field fails then next route is matched. So it's very similar 
to pattern matching in haskell functions.

It has a problem though. There may be inconsitencies. For example:

 > /         HomeR
 > /#String  StrR
 > /#Int     IntR

Then roundtrip (route → URL → route) for IntR becomes:
 > IntR 42 → "/42" → StrR "42"


IMHO overlapping should be disabled by default. Should it be possible to 
enable overlapping? How should it be resolved. Method above seems
to be most intuitive (at least for me).

P.S. I didn't touch subsites and multipiece parts for simplicity.



More information about the web-devel mailing list