Enclose entire app response in single Tx

This commit is contained in:
Joe Nelson
2014-12-12 13:55:09 -08:00
parent d763e27bb2
commit 19b62c00ee
7 changed files with 47 additions and 38 deletions
+6 -2
View File
@@ -44,10 +44,14 @@ pgSettings = H.Postgres "localhost" 5432 "dbapi_test" "" "dbapi_test"
withApp :: ActionWith Application -> IO ()
withApp perform =
let anonRole = cs $ configAnonRole cfg in
perform $ middle $ \req resp ->
H.session pgSettings testSettings $ H.sessionUnlifter >>= \unlift ->
liftIO $ resp =<< catchJust isSqlError
(unlift $ authenticated (cs $ configAnonRole cfg) app req)
liftIO $ do
body <- strictRequestBody req
resp =<< catchJust isSqlError
(unlift $ H.tx Nothing
$ authenticated anonRole (app body) req)
sqlErrHandler
where middle = cors corsPolicy