[web-devel] WAI routing?
yi huang
yi.codeplayer at gmail.com
Sat Mar 17 14:02:19 CET 2012
On Sat, Mar 17, 2012 at 11:06 AM, Stephen Paul Weber <
singpolyma at 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel
>
>
--
http://www.yi-programmer.com/blog/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20120317/81798463/attachment.htm>
More information about the web-devel
mailing list