I'm trying to extract a basic post request using code from this question (except that I'm using lbsBackEnd
instead of the no-longer-existing lbsSink
).
{-# LANGUAGE OverloadedStrings #-}
import Network.Wai.Handler.Warp (run)
import qualified Data.ByteString.Char8 as C
import Network.Wai.Parse (parseRequestBody, lbsBackEnd)
import Network.Wai(Response(..))
import Network.HTTP.Types(status200)
import Blaze.ByteString.Builder
main = run 3000 app
app req = do
(params, _) <- parseRequestBody lbsBackEnd req
let r = C.concat $ map (\(x,y) -> C.concat [x,y]) params
return $ ResponseBuilder
status200
[("Content-Type", "text/plain")]
$ fromByteString r
Comments in that question suggest that this should work, but I'm getting the type error
Couldn't match expected type `C.ByteString'
with actual type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString'
Expected type: [(C.ByteString, C.ByteString)]
Actual type: [Network.Wai.Parse.Param]
In the second argument of `map', namely `params'
In the second argument of `($)', namely
Which is a bit odd because Network.Wai.Parse docs say that Param
is a type synonym for (ByteString, ByteString)
, so as far as I can tell, this should work.
Any tips on what I'm doing wrong?