15:09:51 <jonkri> i want to read the request body of a post request as a json object. how can i do this with happstack?
15:11:20 <jonkri> (i'm happy with accessing it as a string :))
15:12:01 <dcoutts> jonkri: what I do is this:
15:12:04 <dcoutts> consumeRequestBody :: Happstack m => m BS.ByteString
15:12:05 <dcoutts> consumeRequestBody = do
15:12:05 <dcoutts>     mRq <- takeRequestBody =<< askRq
15:12:05 <dcoutts>     case mRq of
15:12:05 <dcoutts>       Nothing -> escape $ internalServerError $ toResponse
15:12:05 <dcoutts>                    "consumeRequestBody cannot be called more than once."
15:12:07 <dcoutts>       Just (Body b) -> return b
15:12:27 <jonkri> thanks dcoutts :)
15:13:07 <dcoutts> jonkri: then on top of that some other stuff, you can see here:
15:13:32 <dcoutts> http://code.haskell.org/hackage-server/Distribution/Server/Framework/RequestContentTypes.hs
15:14:02 <dcoutts> see expectAesonContent, and the thing it uses there, expectContentType
15:14:40 <jonkri> thanks
15:14:43 <dcoutts> jonkri: for some reason, happstack doesn't seem to have much helpful support for the request body except when the body is a POST form type
15:15:06 <dcoutts> but building it up from the low level support isn't hard
15:15:57 <jonkri> ok
15:16:28 <dcoutts> jonkri: feel free to steal that code, it's all BSD
15:17:02 <jonkri> ok :)
15:58:00 <jonkri> how can the string "{'items':[1,2,3,4,5],'orderDate':'200425','deliveryDate':'20130426','status':'funny'}" not be decoded to a data Order = Order { items :: [Integer], orderDate :: String, deliveryDate :: String, status :: String } deriving (Generic, Show) provided an instance FromJSON Order?
15:58:30 <jonkri> (a derived instance of FromJSON)
16:02:27 <bergmark> jonkri: ' is not valid JSON, that might be it
16:03:18 <jonkri> gah :D
16:04:13 <bergmark> working now?
16:05:11 <jonkri> that was it, thanks :)
16:05:21 <jonkri> was going a little crazy there for a while :)