add Yesod.Core.Unsafe module
This commit is contained in:
parent
eeb0bb57d1
commit
05f2a7631c
@ -61,7 +61,7 @@ module Yesod.Core
|
|||||||
-- * Misc
|
-- * Misc
|
||||||
, yesodVersion
|
, yesodVersion
|
||||||
, yesodRender
|
, yesodRender
|
||||||
, runFakeHandler
|
, Yesod.Core.runFakeHandler
|
||||||
-- * LiteApp
|
-- * LiteApp
|
||||||
, module Yesod.Core.Internal.LiteApp
|
, module Yesod.Core.Internal.LiteApp
|
||||||
-- * Low-level
|
-- * Low-level
|
||||||
@ -121,7 +121,8 @@ import Yesod.Core.Internal.Run (yesodRunner)
|
|||||||
import Yesod.Core.Class.Yesod
|
import Yesod.Core.Class.Yesod
|
||||||
import Yesod.Core.Class.Dispatch
|
import Yesod.Core.Class.Dispatch
|
||||||
import Yesod.Core.Class.Breadcrumbs
|
import Yesod.Core.Class.Breadcrumbs
|
||||||
import Yesod.Core.Internal.Run (yesodRender, runFakeHandler)
|
import Yesod.Core.Internal.Run (yesodRender)
|
||||||
|
import qualified Yesod.Core.Internal.Run
|
||||||
import qualified Paths_yesod_core
|
import qualified Paths_yesod_core
|
||||||
import Data.Version (showVersion)
|
import Data.Version (showVersion)
|
||||||
import Yesod.Routes.Class
|
import Yesod.Routes.Class
|
||||||
@ -137,6 +138,15 @@ import Text.Lucius
|
|||||||
import Text.Julius
|
import Text.Julius
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
|
|
||||||
|
runFakeHandler :: (Yesod site, MonadIO m) =>
|
||||||
|
SessionMap
|
||||||
|
-> (site -> Logger)
|
||||||
|
-> site
|
||||||
|
-> HandlerT site IO a
|
||||||
|
-> m (Either ErrorResponse a)
|
||||||
|
runFakeHandler = Yesod.Core.Internal.Run.runFakeHandler
|
||||||
|
{-# DEPRECATED runFakeHandler "import runFakeHandler from Yesod.Core.Unsafe" #-}
|
||||||
|
|
||||||
-- | Return an 'Unauthorized' value, with the given i18n message.
|
-- | Return an 'Unauthorized' value, with the given i18n message.
|
||||||
unauthorizedI :: (MonadHandler m, RenderMessage (HandlerSite m) msg) => msg -> m AuthResult
|
unauthorizedI :: (MonadHandler m, RenderMessage (HandlerSite m) msg) => msg -> m AuthResult
|
||||||
unauthorizedI msg = do
|
unauthorizedI msg = do
|
||||||
|
|||||||
@ -247,7 +247,6 @@ runFakeHandler fakeSessionMap logger site handler = liftIO $ do
|
|||||||
}
|
}
|
||||||
_ <- runResourceT $ yapp fakeRequest
|
_ <- runResourceT $ yapp fakeRequest
|
||||||
I.readIORef ret
|
I.readIORef ret
|
||||||
{-# WARNING runFakeHandler "Usually you should *not* use runFakeHandler unless you really understand how it works and why you need it." #-}
|
|
||||||
|
|
||||||
yesodRunner :: (ToTypedContent res, Yesod site)
|
yesodRunner :: (ToTypedContent res, Yesod site)
|
||||||
=> HandlerT site IO res
|
=> HandlerT site IO res
|
||||||
|
|||||||
23
yesod-core/Yesod/Core/Unsafe.hs
Normal file
23
yesod-core/Yesod/Core/Unsafe.hs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
-- | This is designed to be used as
|
||||||
|
--
|
||||||
|
-- > qualifyed import Yesod.Core.Unsafe as Unsafe
|
||||||
|
--
|
||||||
|
-- This serves as a reminder that the functions are unsafe to use in many situations.
|
||||||
|
module Yesod.Core.Unsafe (runFakeHandler, fakeHandlerGetLogger) where
|
||||||
|
|
||||||
|
import Yesod.Core.Internal.Run (runFakeHandler)
|
||||||
|
|
||||||
|
import Yesod.Core.Types
|
||||||
|
import Yesod.Core.Class.Yesod
|
||||||
|
import Data.Monoid (mempty, mappend)
|
||||||
|
import Control.Monad.IO.Class (MonadIO)
|
||||||
|
|
||||||
|
-- | designed to be used as
|
||||||
|
--
|
||||||
|
-- > unsafeHandler = Unsafe.fakeHandlerGetLogger appLogger
|
||||||
|
fakeHandlerGetLogger :: (Yesod site, MonadIO m)
|
||||||
|
=> (site -> Logger) -> site -> HandlerT site IO a -> m a
|
||||||
|
fakeHandlerGetLogger getLogger app f =
|
||||||
|
runFakeHandler mempty getLogger app f
|
||||||
|
>>= either (error . ("runFakeHandler issue: " `mappend`) . show)
|
||||||
|
return
|
||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-core
|
name: yesod-core
|
||||||
version: 1.4.5
|
version: 1.4.6
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
@ -77,6 +77,7 @@ library
|
|||||||
Yesod.Core.Widget
|
Yesod.Core.Widget
|
||||||
Yesod.Core.Internal
|
Yesod.Core.Internal
|
||||||
Yesod.Core.Types
|
Yesod.Core.Types
|
||||||
|
Yesod.Core.Unsafe
|
||||||
Yesod.Routes.TH.Types
|
Yesod.Routes.TH.Types
|
||||||
other-modules: Yesod.Core.Internal.Session
|
other-modules: Yesod.Core.Internal.Session
|
||||||
Yesod.Core.Internal.Request
|
Yesod.Core.Internal.Request
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user