Network.Wai
및 Warp
을 사용하여 POST 요청에서 데이터를 검색하는 방법은 무엇입니까?Warp/WAI를 사용하여 POST 처리
말 예를 들어, 나는이 데이터를 검색하는 방법을 간단한 웹 페이지를 사용자가 클릭 제출
....
<form method="POST" action="/handlepost">
<input name="name" type="text" />
<input type="submit" />
</form>
....
을 가지고? 나는 그것이받은 것처럼, POST 데이터가 요청 본문에서 처리되지 않은 남아 있도록 WAI는 매우 낮은 수준의 인터페이스 예를
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?
또한 http://langnostic.blogspot.de/2013/04/simple-web-chat-using-haskells-waiwarp.html은'parseRequestBody'를 사용할 수있는 좋은 예를 제공합니다. 'wai-extra' 문서는'Sink x y' 타입의 인자를 설정할 때 약간 성가시다. – eugenk