对不起我的基本问题,但我是 Haskell 的新手。
我正在按照此示例从请求正文中接收一些值,但我的服务器还使用以下代码从目录提供静态文件:
fileServing :: ServerPart Response
fileServing = serveDirectory EnableBrowsing ["index.html"] "./Path/"
mainFunc = simpleHTTP nullConf $ msum [
fileServing
]
我将以下代码添加到我的库中,但我不确定在哪里使用该handlers
函数,因为我已经msum
在mainFunc
.
handlers :: ServerPart Response
handlers =
do decodeBody myPolicy
msum [
myGetData
]
myGetData :: ServerPart Response
myGetData =
do method POST
username <- look "username"
password <- look "password"
ok $ toResponse (username ++ ", " ++ password)