flip app args
This commit is contained in:
+2
-2
@@ -84,8 +84,8 @@ httpRequesterRole hdrs conn = do
|
|||||||
_ -> return NoCredentials
|
_ -> return NoCredentials
|
||||||
|
|
||||||
|
|
||||||
app :: Connection -> DbRole -> Application
|
app :: DbRole -> Connection -> Application
|
||||||
app conn anonymous req respond = do
|
app anonymous conn req respond = do
|
||||||
attempt <- httpRequesterRole (requestHeaders req) conn
|
attempt <- httpRequesterRole (requestHeaders req) conn
|
||||||
|
|
||||||
case attempt of
|
case attempt of
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ main = do
|
|||||||
|
|
||||||
Prelude.putStrLn $ "Listening on port " ++ (show $ configPort conf :: String)
|
Prelude.putStrLn $ "Listening on port " ++ (show $ configPort conf :: String)
|
||||||
conn <- connectPostgreSQL' dburi
|
conn <- connectPostgreSQL' dburi
|
||||||
runTLS tls settings $ gzip def $ cors corsPolicy $ reportPgErrors $ app conn (cs $ configAnonRole conf)
|
runTLS tls settings $ gzip def $ cors corsPolicy $ reportPgErrors $ app (cs $ configAnonRole conf) conn
|
||||||
|
|
||||||
where
|
where
|
||||||
describe = progDesc "create a REST API to an existing Postgres database"
|
describe = progDesc "create a REST API to an existing Postgres database"
|
||||||
|
|||||||
+2
-2
@@ -59,14 +59,14 @@ withUser name pass role action conn = do
|
|||||||
withApp :: ActionWith Application -> ActionWith Connection
|
withApp :: ActionWith Application -> ActionWith Connection
|
||||||
withApp action conn = do
|
withApp action conn = do
|
||||||
runRaw conn "begin;"
|
runRaw conn "begin;"
|
||||||
action $ cors corsPolicy $ app conn "dbapi_anonymous"
|
action $ cors corsPolicy $ app "dbapi_anonymous" conn
|
||||||
rollback conn
|
rollback conn
|
||||||
|
|
||||||
appWithFixture :: ActionWith Application -> IO ()
|
appWithFixture :: ActionWith Application -> IO ()
|
||||||
appWithFixture action = withDatabaseConnection $ \c -> do
|
appWithFixture action = withDatabaseConnection $ \c -> do
|
||||||
result <- tryJust transactionAborted $ do
|
result <- tryJust transactionAborted $ do
|
||||||
runRaw c "begin;"
|
runRaw c "begin;"
|
||||||
action $ cors corsPolicy $ app c "dbapi_anonymous"
|
action $ cors corsPolicy $ app "dbapi_anonymous" c
|
||||||
rollback c
|
rollback c
|
||||||
|
|
||||||
when (isLeft result) $
|
when (isLeft result) $
|
||||||
|
|||||||
Reference in New Issue
Block a user