【发布时间】:2016-03-06 16:49:12
【问题描述】:
如何使用 Network.Wai 和 Warp 从 POST 请求中检索数据?
比如说,我有一个简单的网页
....
<form method="POST" action="/handlepost">
<input name="name" type="text" />
<input type="submit" />
</form>
....
当用户点击提交时,我该如何检索这些数据?我知道如何获取 GET 数据 (queryString)
例如
app :: Application
app request = case rawPathInfo request of
"/" -> return $ displayForm
"/handlePost" -> return $ handlepost
_ -> return $ notFound
displayForm :: Response
displayForm = ResponseBuilder
status200
[("Content-Type", "text/html")] $
fromByteString "<form method='POST' action='/handlepost'><input name="name" type="text" /><input type='submit'></form>"
handlePost :: Request -> Response
handlePost req = undefined -- how do I examine the contents of POST?
【问题讨论】:
标签: haskell haskell-warp