[web-devel] WAI routing?
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
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the web-devel