Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

runHandler, evalHander do not include an environment argument. Patch

mirrors format of Snap.Snaplet.Internal.Initializer.runSnaplet.
  • Loading branch information...
commit 9e9f79618ae3a0ea87b460bd470eb9fda994b300 1 parent 7da5a64
@cjeast cjeast authored
Showing with 13 additions and 9 deletions.
  1. +13 −9 src/Snap/Snaplet/Test.hs
View
22 src/Snap/Snaplet/Test.hs
@@ -15,6 +15,7 @@ import Control.Concurrent.MVar
import Control.Exception.Base (finally)
import qualified Control.Exception as E
import Control.Monad.IO.Class
+import Data.Maybe (fromMaybe)
import Data.Text
import System.Directory
import System.IO.Error
@@ -56,12 +57,13 @@ removeFileMayNotExist f = catchNonExistence (removeFile f) ()
-- 'runHandler' defined in Snap.Test, because due to the fact running
-- the initializer inside 'SnapletInit' can throw an exception.
runHandler :: MonadIO m
- => RequestBuilder m ()
+ => Maybe String
+ -> RequestBuilder m ()
-> Handler b b a
-> SnapletInit b b
-> m (Either Text Response)
-runHandler rq h s = do
- app <- getSnaplet s
+runHandler env rq h s = do
+ app <- getSnaplet env s
case app of
(Left e) -> return $ Left e
(Right (a,_)) -> do
@@ -81,12 +83,13 @@ runHandler rq h s = do
-- 'evalHandler defined in Snap.Test, because due to the fact running
-- the initializer inside 'SnapletInit' can throw an exception.
evalHandler :: MonadIO m
- => RequestBuilder m ()
+ => Maybe String
+ -> RequestBuilder m ()
-> Handler b b a
-> SnapletInit b b
-> m (Either Text a)
-evalHandler rq h s = do
- app <- getSnaplet s
+evalHandler env rq h s = do
+ app <- getSnaplet env s
case app of
(Left e) -> return $ Left e
(Right (a,_)) -> do
@@ -99,10 +102,11 @@ evalHandler rq h s = do
-- a @Snaplet b@, or an error message whether the initializer threw an
-- exception.
getSnaplet :: MonadIO m
- => SnapletInit b b
+ => Maybe String
+ -> SnapletInit b b
-> m (Either Text (Snaplet b, InitializerState b))
-getSnaplet (SnapletInit initializer) = liftIO $ do
+getSnaplet env (SnapletInit initializer) = liftIO $ do
mvar <- newEmptyMVar
let resetter f = modifyMVar_ mvar (return . f)
- runInitializer resetter "" initializer
+ runInitializer resetter (fromMaybe "devel" env) initializer
Please sign in to comment.
Something went wrong with that request. Please try again.