packages feed

Spock 0.4.3.0 → 0.4.3.1

raw patch · 2 files changed

+17/−3 lines, 2 filesdep +path-piecesdep −aeson

Dependencies added: path-pieces

Dependencies removed: aeson

Files

Spock.cabal view
@@ -1,5 +1,5 @@ name:                Spock-version:             0.4.3.0+version:             0.4.3.1 synopsis:            Another Haskell web toolkit based on scotty description:         This toolbox provides everything you need to get a quick start into web hacking with haskell: sessions, cookies, database helper, global state and the power of scotty Homepage:            https://github.com/agrafix/Spock@@ -38,11 +38,11 @@                        transformers ==0.3.*,                        transformers-base ==0.4.*,                        xsd ==0.4.*,-                       aeson >=0.6,                        resource-pool ==0.2.*,                        random ==1.*,                        pool-conduit ==0.1.*,-                       vault ==0.3.*+                       vault ==0.3.*,+                       path-pieces ==0.1.*   ghc-options: -Wall -fno-warn-orphans  source-repository head
Web/Spock.hs view
@@ -24,6 +24,8 @@     , text, html, file, json, source, raw     , raise, rescue, next     , RoutePattern+      -- * Spock utilities+    , paramPathPiece       -- * Internals for extending Spock     , getSpockHeart, runSpockIO, WebStateM, WebState     )@@ -39,7 +41,9 @@ import Control.Monad.Trans.Resource import Data.Pool import Web.Scotty.Trans+import Web.PathPieces import qualified Network.HTTP.Types as Http+import qualified Data.Text.Lazy as TL  -- | Run a spock application using the warp server, a given db storageLayer and an initial state. -- Spock works with database libraries that already implement connection pooling and@@ -89,3 +93,13 @@ readSession =     do mgr <- getSessMgr        sm_readSession mgr++-- | Same as "param", but the target type needs to implement "PathPiece"+paramPathPiece :: PathPiece s => TL.Text -> SpockAction conn sess st s+paramPathPiece t =+    do val <- param t+       case fromPathPiece val of+         Just x ->+             return x+         Nothing ->+             raise $ stringError $ "Cannot convert param: " ++ TL.unpack t ++ " to path piece!"