On Sat, Mar 17, 2012 at 11:06 AM, Stephen Paul Weber
<singpolyma@singpolyma.net> wrote:
I looked around, but could not find a lot of routing packages for WAI. There is wai-routes, but QuasiQuote makes me nervous.
So, I hacked together a very simple router (attached). It works, though it is not efficient for large routing tables (it just does a linear scan over all possible routes in the worst case).
I'm curious: (a) what are other people using? (b) are there glaringly stupid things I've done in my code?
Thanks :)
I use plain case expression to do routing for my simple wai applications, ghc's desugar can make it more efficent than linear scan, the code is like this:
case (requestMethod req, pathInfo req) of
("GET", []) -> index
("GET", ["object", pk]) -> getObject pk
("POST", ["object", pk]) -> jsonBody >>= updateObject pk
_ -> bad status404 "no route match"
--
Stephen Paul Weber, @singpolyma
See <http://singpolyma.net> for how I prefer to be contacted
edition right joseph
_______________________________________________
web-devel mailing list
web-devel@haskell.org
http://www.haskell.org/mailman/listinfo/web-devel