我正在尝试使用此问题中的代码提取基本的发布请求(除了我正在使用lbsBackEnd
而不是不再存在的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
该问题中的评论表明这应该可行,但我收到类型错误
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
这有点奇怪,因为Network.Wai.Parse文档说这Param
是 的类型同义词(ByteString, ByteString)
,据我所知,这应该有效。
关于我做错了什么的任何提示?