{-# LANGUAGE TemplateHaskell, QuasiQuotes, OverloadedStrings #-}
{-# LANGUAGE MultiParamTypeClasses, TypeFamilies #-}
import Yesod
import Control.Monad (void)
data Foo = Foo
mkYesod "Foo" [parseRoutes|
/ FooR POST
|]
instance Yesod Foo
-- Always prints "".
postFooR = void $
getRequest >>= liftIO . print . ("Params :" ++) . concatMap show . reqGetParams
main = warp 3000 Foo
我正在通过几个Yesod教程,但我仍然试图检查POST参数。以下是运行上述代码时发生的情况:
$ runhaskell foo.hs
$ curl --data "foo=bar" localhost:3000
14/Jul/2013:15:01:51 -0700 [Info#yesod-core] Application launched @(yesod-core-1.2.3:Yesod.Core.Dispatch ./Yesod/Core/Dispatch.hs:129:11)
"Params: "
127.0.0.1 - - [14/Jul/2013:15:02:07 -0700] "POST / HTTP/1.1" 200 - "" "curl/7.30.0"
我做错了什么?谢谢!