[web-devel] Examples and/or tutorials for WAI

Neil Mitchell ndmitchell at gmail.com
Sat Feb 12 10:12:45 CET 2011

Hi Thomas,

>> What tripped me up was trying to figure out the enumerator part of the
>> API so that I can read the request body (and turn it into a String)
>> and run the XML-RPC request handler. Any help would be appreciated!

In Hoogle I use, responseLBS to construct responses (from Wai), and
responseFlatten to deconstruct them:

responseFlatten :: Response -> IO (Status, ResponseHeaders, LBString)
responseFlatten r = responseEnumerator r $ \s hs -> do
       builders <- consume
       return (s, hs, toLazyByteString $ mconcat builders)

Now you can avoid knowledge of anything to do with enumerators etc.
(which I still don't understand!)

Thanks, Neil

More information about the web-devel mailing list