Routers match unexpected hanlders

14 views
Skip to first unread message

Haisheng Wu

unread,
May 1, 2012, 5:49:18 AM5/1/12
to sn...@snapframework.com
Hi there,
 I defined one route as
`("/book", theBookHandler)`

While a browse a URL <http://localhost/book/123>, snap just use
`theBookHandler`.
However I expect it show me error like "No Handler found".

My question is that whether this is a desired behaviors currently?

My working enviornment:
- ubuntu 11.04
- snap-0.8-0
- snap-server-0.8.1.1
- snap-core-0.8.1

Thanks a lot your help.
-Simon

mightybyte

unread,
Jun 6, 2012, 1:08:23 PM6/6/12
to snap_fr...@googlegroups.com, sn...@snapframework.com
Hi, I've had some trouble with my mail client and didn't see this question until just now.  The route function (http://hackage.haskell.org/packages/archive/snap-core/0.8.1/doc/html/Snap-Core.html#v:route) is designed primarily for matching route prefixes rather than whole routes because I think it's more powerful and it's usually what people want.  To do what you want to do, use the "ifTop" function.  It only executes its argument handler if there is nothing left to be matched in the route.  It would look like this:

("/book", ifTop theBookHandler)
Reply all
Reply to author
Forward
0 new messages