[web-devel] WAI routing?
greg at gregweber.info
Sat Mar 17 15:32:45 CET 2012
you might be interested in looking at the routing code in scotty,
which has some extra features.
On Sat, Mar 17, 2012 at 6:02 AM, yi huang <yi.codeplayer at gmail.com> wrote:
> 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
> web-devel mailing list
> web-devel at haskell.org
More information about the web-devel