[web-devel] Overlapping in routes

Michael Snoyman michael at snoyman.com
Sun Jun 26 07:13:39 CEST 2011


Hi Alexey,

Simple answer is that overlapping is disabled by default. If you want
to allow overlapping, you have to use a separate parseRoutesNoChecking
function, which is not exported from Yesod by default (you have to
look in web-routes-quasi).

Michael

On Thu, Jun 23, 2011 at 11:42 PM, Alexey Khudyakov
<alexey.skladnoy at gmail.com> wrote:
> 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.
>
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel
>



More information about the web-devel mailing list