packages feed

yesod-core 1.4.1.1 → 1.4.2

raw patch · 4 files changed

+26/−7 lines, 4 files

Files

Yesod/Core/Class/Yesod.hs view
@@ -14,10 +14,12 @@ import           Blaze.ByteString.Builder           (Builder) import           Blaze.ByteString.Builder.Char.Utf8 (fromText) import           Control.Arrow                      ((***), second)+import           Control.Exception                  (bracket) import           Control.Monad                      (forM, when, void) import           Control.Monad.IO.Class             (MonadIO (liftIO)) import           Control.Monad.Logger               (LogLevel (LevelInfo, LevelOther),                                                      LogSource)+import           Control.Monad.Trans.Resource       (InternalState, createInternalState, closeInternalState) import qualified Data.ByteString.Char8              as S8 import qualified Data.ByteString.Lazy               as L import Data.Aeson (object, (.=))@@ -283,6 +285,20 @@     -- Since: 1.1.6     yesodMiddleware :: ToTypedContent res => HandlerT site IO res -> HandlerT site IO res     yesodMiddleware = defaultYesodMiddleware++    -- | How to allocate an @InternalState@ for each request.+    --+    -- The default implementation is almost always what you want. However, if+    -- you know that you are never taking advantage of the @MonadResource@+    -- instance in your handler functions, setting this to a dummy+    -- implementation can provide a small optimization. Only do this if you+    -- really know what you're doing, otherwise you can turn safe code into a+    -- runtime error!+    --+    -- Since 1.4.2+    yesodWithInternalState :: site -> Maybe (Route site) -> (InternalState -> IO a) -> IO a+    yesodWithInternalState _ _ = bracket createInternalState closeInternalState+    {-# INLINE yesodWithInternalState #-}  -- | Default implementation of 'yesodMiddleware'. Adds the response header -- \"Vary: Accept, Accept-Language\" and performs authorization checks.
Yesod/Core/Internal/Run.hs view
@@ -18,7 +18,7 @@ import           Control.Monad.IO.Class       (liftIO) import           Control.Monad.Logger         (LogLevel (LevelError), LogSource,                                                liftLoc)-import           Control.Monad.Trans.Resource (runResourceT, withInternalState, runInternalState, createInternalState, closeInternalState)+import           Control.Monad.Trans.Resource (runResourceT, withInternalState, runInternalState) import qualified Data.ByteString              as S import qualified Data.ByteString.Char8        as S8 import qualified Data.IORef                   as I@@ -278,7 +278,7 @@             { rheOnError = runHandler rheSafe . errorHandler             } -    E.bracket createInternalState closeInternalState $ \is -> do+    yesodWithInternalState yreSite route $ \is -> do         yreq' <- yreq         yar <- runInternalState (runHandler rhe handler yreq') is         yarToResponse yar saveSession yreq' req is sendResponse
Yesod/Routes/Class.hs view
@@ -10,12 +10,15 @@ import Data.Set (Set)  class Eq (Route a) => RenderRoute a where-    -- | The type-safe URLs associated with a site argument.+    -- | The <http://www.yesodweb.com/book/routing-and-handlers type-safe URLs> associated with a site argument.     data Route a-    renderRoute :: Route a -> ([Text], [(Text, Text)])+    renderRoute :: Route a+                -> ([Text], [(Text, Text)]) -- ^ The path of the URL split on forward slashes, and a list of query parameters with their associated value.  class RenderRoute a => ParseRoute a where-    parseRoute :: ([Text], [(Text, Text)]) -> Maybe (Route a)+    parseRoute :: ([Text], [(Text, Text)]) -- ^ The path of the URL split on forward slashes, and a list of query parameters with their associated value.+               -> Maybe (Route a)  class RenderRoute a => RouteAttrs a where-    routeAttrs :: Route a -> Set Text+    routeAttrs :: Route a+               -> Set Text -- ^ A set of <http://www.yesodweb.com/book/route-attributes attributes associated with the route>.
yesod-core.cabal view
@@ -1,5 +1,5 @@ name:            yesod-core-version:         1.4.1.1+version:         1.4.2 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>