Skip to content

Commit

Permalink
add some basic tests for the cleanup machinery in Delayed
Browse files Browse the repository at this point in the history
  • Loading branch information
alpmestan committed Jan 12, 2017
1 parent 81a876c commit 12a1dc1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions servant-server/servant-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ test-suite spec
Servant.ArbitraryMonadServerSpec
Servant.Server.ErrorSpec
Servant.Server.Internal.ContextSpec
Servant.Server.Internal.RoutingApplicationSpec
Servant.Server.RouterSpec
Servant.Server.StreamingSpec
Servant.Server.UsingContextSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{-# LANGUAGE TupleSections #-}
module Servant.Server.Internal.RoutingApplication where

import Control.Exception (bracket)
import Control.Exception (finally)
import Control.Monad (ap, liftM, (>=>))
import Control.Monad.Trans (MonadIO(..))
import Control.Monad.Trans.Except (runExceptT)
Expand Down Expand Up @@ -289,9 +289,8 @@ runAction :: Delayed env (Handler a)
-> IO r
runAction action env req respond k = do
cleanupRef <- newCleanupRef
bracket (runDelayed action env req cleanupRef)
(const $ runCleanup cleanupRef)
(go >=> respond)
(runDelayed action env req cleanupRef >>= go >>= respond)
`finally` runCleanup cleanupRef

where
go (Fail e) = return $ Fail e
Expand Down

0 comments on commit 12a1dc1

Please sign in to comment.