How do you retrieve data from a POST request using Network.Wai
and Warp
?
Say for example, I have a simple webpage
....
<form method="POST" action="/handlepost">
<input name="name" type="text" />
<input type="submit" />
</form>
....
When the user clicks submit, how can I retrieve this data? I know how to get GET data (queryString
)
for example
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?
parseRequestBody
can be used. Thewai-extra
documentation is a little cumbersome when it comes to setting the argument of typeSink x y
right. – Kinsman