| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Web.Spock
Description
Build an application with typed routes, sessions, and a database pool.
Reading requests and sending responses
Request and response helpers are reexported from Web.Spock.Action in the
Spock-core package. Follow that module link for the complete action API:
paramandparam': parse query or form parameters. Values captured byvarin a route are passed directly to its handler instead.paramsGet,paramsPost, andparams: list request parameters.jsonBody,jsonBody', andbody: read JSON or raw request bytes.header,rawHeader, andcookies: inspect request metadata.filesMulti: read uploaded files, including repeated upload fields.setStatusandsetHeader: prepare response metadata before sending it.text,html,json,file, andlazyBytes: send a response and finish the current action.
The API reference links the current versions of Spock, Spock-core, the typed API packages, and session adapters.
Synopsis
- runSpock :: Port -> IO Middleware -> IO ()
- runSpockNoBanner :: Port -> IO Middleware -> IO ()
- spockAsApp :: IO Middleware -> IO Application
- spock :: SpockCfg conn sess st -> SpockM conn sess st () -> IO Middleware
- type SpockM conn sess st = SpockCtxM () conn sess st
- type SpockCtxM ctx conn sess st = SpockCtxT ctx (WebStateM conn sess st)
- data Path (as :: [Type]) (pathState :: PathState)
- root :: Path ('[] :: [Type]) 'Open
- type Var a = Path '[a] 'Open
- data AltVar a b
- var :: (Typeable a, FromHttpApiData a) => Path '[a] 'Open
- static :: String -> Path ('[] :: [Type]) 'Open
- trailingSlash :: forall (as :: [Type]). Path as 'Open -> Path as 'Open
- (<//>) :: forall (as :: [Type]) (bs :: [Type]) (ps :: PathState). Path as 'Open -> Path bs ps -> Path (Append as bs) ps
- (<.>) :: forall (as :: [Type]) (bs :: [Type]). Path as 'Open -> Path bs 'Open -> Path (Append as bs) 'Open
- wildcard :: Path '[Text] 'Closed
- renderRoute :: forall (as :: [Type]). AllHave ToHttpApiData as => Path as 'Open -> HVectElim as Text
- renderRouteWith :: forall (as :: [Type]). AllHave ToHttpApiData as => SlashPolicy -> Path as 'Open -> HVectElim as Text
- renderRouteEncoded :: forall (as :: [Type]). AllHave ToHttpApiData as => Path as 'Open -> HVectElim as Text
- renderRouteEncodedWith :: forall (as :: [Type]). AllHave ToHttpApiData as => SlashPolicy -> Path as 'Open -> HVectElim as Text
- prehook :: forall t (m :: Type -> Type) ctx ctx'. (RouteM t, MonadIO m) => ActionCtxT ctx m ctx' -> t ctx' m () -> t ctx m ()
- type RouteSpec (t :: Type -> (Type -> Type) -> Type -> Type) (xs :: [Type]) (ps :: PathState) ctx conn sess st = Path xs ps -> HVectElim xs (SpockActionCtx ctx conn sess st ()) -> RouteMonad t ctx conn sess st ()
- get :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st
- post :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st
- getpost :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st
- head :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st
- put :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st
- delete :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st
- patch :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st
- hookRoute :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => StdMethod -> RouteSpec t xs ps ctx conn sess st
- hookRouteCustom :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => Text -> RouteSpec t xs ps ctx conn sess st
- hookAny :: StdMethod -> ([Text] -> SpockActionCtx ctx conn sess st ()) -> RouteMonad t ctx conn sess st ()
- hookAnyCustom :: Text -> ([Text] -> SpockActionCtx ctx conn sess st ()) -> RouteMonad t ctx conn sess st ()
- hookRouteAll :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st
- hookAnyAll :: ([Text] -> SpockActionCtx ctx conn sess st ()) -> RouteMonad t ctx conn sess st ()
- data StdMethod
- middleware :: forall t (m :: Type -> Type) ctx. (RouteM t, Monad m) => Middleware -> t ctx m ()
- type SpockAction conn sess st = SpockActionCtx () conn sess st
- type SpockActionCtx ctx conn sess st = ActionCtxT ctx (WebStateM conn sess st)
- module Web.Spock.Action
- class HasSpock (m :: Type -> Type) where
- type SpockConn (m :: Type -> Type)
- type SpockState (m :: Type -> Type)
- type SpockSession (m :: Type -> Type)
- runQuery :: (SpockConn m -> IO a) -> m a
- getState :: m (SpockState m)
- getSessMgr :: m (SpockSessionManager (SpockConn m) (SpockSession m) (SpockState m))
- getSpockCfg :: m (SpockCfg (SpockConn m) (SpockSession m) (SpockState m))
- data SessionManager (m :: Type -> Type) conn sess st
- module Web.Spock.SessionActions
- getCsrfToken :: SpockActionCtx ctx conn sess st Text
- getClientCsrfToken :: SpockActionCtx ctx conn sess st (Maybe Text)
- csrfCheck :: SpockActionCtx ctx conn sess st ()
- type WebStateM conn sess st = WebStateT conn sess st (ResourceT IO)
- data WebStateT conn sess st (m :: Type -> Type) a
- data WebState conn sess st
- getSpockHeart :: MonadTrans t => t (WebStateM conn sess st) (WebState conn sess st)
- runSpockIO :: WebState conn sess st -> WebStateM conn sess st a -> IO a
- getSpockPool :: MonadTrans t => t (WebStateM conn sess st) (Pool conn)
Launching Spock
runSpock :: Port -> IO Middleware -> IO () #
Run a Spock application using run from Network.Wai.Handler.Warp.
runSpockNoBanner :: Port -> IO Middleware -> IO () #
Like runSpock, but does not display the banner "Spock is running on port XXX" on stdout.
spockAsApp :: IO Middleware -> IO Application #
Convert a middleware to an application. All failing requests will result in a 404 page
Spock's route definition monad
spock :: SpockCfg conn sess st -> SpockM conn sess st () -> IO Middleware Source #
Create a spock application using a given db storageLayer and an initial state.
Spock works with database libraries that already implement connection pooling and
with those that don't come with it out of the box. For more see the PoolOrConn type.
Use runSpock to run the app or spockAsApp to create a Wai.Application
type SpockM conn sess st = SpockCtxM () conn sess st Source #
Register routes and middleware when the application starts. The handler
passed to a route runs later, once per matching request, in SpockAction.
conn is a database connection, sess is one visitor's session value, and
st is application-wide state. The final result parameter is usually ().
This is SpockCtxM with an empty request context. Use SpockCtxM inside a
prehook that supplies a typed context.
type SpockCtxM ctx conn sess st = SpockCtxT ctx (WebStateM conn sess st) Source #
Route registration with handlers that receive context ctx. A prehook
produces this context per request; getContext reads it in the handler.
Context belongs to the selected request and hook scope, while st is shared
by the entire application and sess belongs to a visitor's session.
The underlying monad is WebStateM: lift helper runs a shared-state or
database helper during registration. Inside a handler, the same expression
runs it for that request. Use liftIO for an ordinary IO operation.
Defining routes
A variant of Either with a FromHttpApiData definition that tries both branches without a prefix.
Useful to define routes with vars that should work with different types.
Instances
| (Eq a, Eq b) => Eq (AltVar a b) | |
| (Ord a, Ord b) => Ord (AltVar a b) | |
| (Read a, Read b) => Read (AltVar a b) | |
| (Show a, Show b) => Show (AltVar a b) | |
| (FromHttpApiData a, FromHttpApiData b) => FromHttpApiData (AltVar a b) | |
static :: String -> Path ('[] :: [Type]) 'Open #
A static route piece. One leading slash is optional. Empty internal and
trailing pieces are retained for strict routing; compatibility routing and
renderRoute ignore them. Use renderRouteWith with the application's policy.
trailingSlash :: forall (as :: [Type]). Path as 'Open -> Path as 'Open #
Require a trailing slash in strict routing, including after a capture. Root remains root, and a path already ending in a slash is unchanged.
(<//>) :: forall (as :: [Type]) (bs :: [Type]) (ps :: PathState). Path as 'Open -> Path bs ps -> Path (Append as bs) ps #
Combine two path components
(<.>) :: forall (as :: [Type]) (bs :: [Type]). Path as 'Open -> Path bs 'Open -> Path (Append as bs) 'Open infixl 8 #
Join the last segment on the left and the first on the right with a dot.
Both sides may contain typed captures: var . "txt" or var . var.
Matching tries the rightmost dot first and accepts the first split whose
typed parsers and literals succeed. Use a custom capture type to restrict
extensions; a Text capture accepts any text, including an empty extension.
Static routes take precedence over extensions, then plain captures and
wildcards. More literal characters give an extension pattern priority.
wildcard :: Path '[Text] 'Closed #
Matches the rest of the route. Should be the last part of the path.
Rendering routes
renderRoute :: forall (as :: [Type]). AllHave ToHttpApiData as => Path as 'Open -> HVectElim as Text #
Render a route applying path pieces
renderRouteWith :: forall (as :: [Type]). AllHave ToHttpApiData as => SlashPolicy -> Path as 'Open -> HVectElim as Text #
Render with the application's slash policy. Use StrictSlashes or
RedirectTrailingSlashes to preserve trailing and repeated literal slashes.
renderRouteEncoded :: forall (as :: [Type]). AllHave ToHttpApiData as => Path as 'Open -> HVectElim as Text #
Render a URL with each complete path segment percent-encoded.
renderRouteEncodedWith :: forall (as :: [Type]). AllHave ToHttpApiData as => SlashPolicy -> Path as 'Open -> HVectElim as Text #
Percent-encoded rendering with the application's slash policy.
Hooking routes
prehook :: forall t (m :: Type -> Type) ctx ctx'. (RouteM t, MonadIO m) => ActionCtxT ctx m ctx' -> t ctx' m () -> t ctx m () #
Specify an action that will be run before all subroutes. It can modify the requests current context
type RouteSpec (t :: Type -> (Type -> Type) -> Type -> Type) (xs :: [Type]) (ps :: PathState) ctx conn sess st = Path xs ps -> HVectElim xs (SpockActionCtx ctx conn sess st ()) -> RouteMonad t ctx conn sess st () Source #
get :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st Source #
Specify an action that will be run when the HTTP verb GET and the given route match
post :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st Source #
Specify an action that will be run when the HTTP verb POST and the given route match
getpost :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st Source #
head :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st Source #
Specify an action that will be run when the HTTP verb HEAD and the given route match
put :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st Source #
Specify an action that will be run when the HTTP verb PUT and the given route match
delete :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st Source #
Specify an action that will be run when the HTTP verb DELETE and the given route match
patch :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st Source #
Specify an action that will be run when the HTTP verb PATCH and the given route match
hookRoute :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => StdMethod -> RouteSpec t xs ps ctx conn sess st Source #
Specify an action that will be run when a standard HTTP verb and the given route match
hookRouteCustom :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => Text -> RouteSpec t xs ps ctx conn sess st Source #
Specify an action that will be run when a custom HTTP verb and the given route match
hookAny :: StdMethod -> ([Text] -> SpockActionCtx ctx conn sess st ()) -> RouteMonad t ctx conn sess st () Source #
Specify an action that will be run when a standard HTTP verb matches but no defined route matches. The full path is passed as an argument
hookAnyCustom :: Text -> ([Text] -> SpockActionCtx ctx conn sess st ()) -> RouteMonad t ctx conn sess st () Source #
Specify an action that will be run when a custom HTTP verb matches but no defined route matches. The full path is passed as an argument
hookRouteAll :: forall (xs :: [Type]) t (ps :: PathState) ctx conn sess st. HasRep xs => RouteSpec t xs ps ctx conn sess st Source #
Specify an action that will be run regardless of the HTTP verb
hookAnyAll :: ([Text] -> SpockActionCtx ctx conn sess st ()) -> RouteMonad t ctx conn sess st () Source #
Specify an action that will be run regardless of the HTTP verb and no defined route matches. The full path is passed as an argument
HTTP standard method (as defined by RFC 2616, and PATCH which is defined by RFC 5789).
Since: http-types-0.2.0
Instances
| Eq StdMethod | |||||
| Ord StdMethod | |||||
Defined in Network.HTTP.Types.Method | |||||
| Data StdMethod | Since: http-types-0.12.4 | ||||
Defined in Network.HTTP.Types.Method Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> StdMethod -> c StdMethod gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c StdMethod toConstr :: StdMethod -> Constr dataTypeOf :: StdMethod -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c StdMethod) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c StdMethod) gmapT :: (forall b. Data b => b -> b) -> StdMethod -> StdMethod gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> StdMethod -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> StdMethod -> r gmapQ :: (forall d. Data d => d -> u) -> StdMethod -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> StdMethod -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> StdMethod -> m StdMethod gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> StdMethod -> m StdMethod gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> StdMethod -> m StdMethod | |||||
| Bounded StdMethod | |||||
Defined in Network.HTTP.Types.Method | |||||
| Enum StdMethod | |||||
Defined in Network.HTTP.Types.Method | |||||
| Generic StdMethod | |||||
Defined in Network.HTTP.Types.Method Associated Types
| |||||
| Ix StdMethod | |||||
| Read StdMethod | |||||
| Show StdMethod | |||||
| type Rep StdMethod # | Since: http-types-0.12.4 | ||||
Defined in Network.HTTP.Types.Method type Rep StdMethod = D1 ('MetaData "StdMethod" "Network.HTTP.Types.Method" "http-typs-0.12.6-c4f7c903" 'False) (((C1 ('MetaCons "GET" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "POST" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "HEAD" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PUT" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "DELETE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TRACE" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CONNECT" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OPTIONS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PATCH" 'PrefixI 'False) (U1 :: Type -> Type))))) | |||||
Adding Wai.Middleware
middleware :: forall t (m :: Type -> Type) ctx. (RouteM t, Monad m) => Middleware -> t ctx m () #
Hook wai middleware into Spock
Actions
type SpockAction conn sess st = SpockActionCtx () conn sess st Source #
A per-request SpockActionCtx with context (). This is the usual handler
type outside a prehook. Its conn, sess, and st parameters have the same
meanings as in the application's route-registration type.
type SpockActionCtx ctx conn sess st = ActionCtxT ctx (WebStateM conn sess st) Source #
A per-request action with typed context ctx, database connection conn,
session value sess, and shared application state st. The final type
parameter is the action's result. Use getContext for the value supplied by
a prehook, getState for shared state, and session actions for this visitor.
This is ActionCtxT over WebStateM. lift helper enters WebStateM;
liftIO operation runs IO. Sending a response finishes the action even
though response helpers have a polymorphic result type.
module Web.Spock.Action
class HasSpock (m :: Type -> Type) where Source #
Access application services in WebStateM and Spock's registration/action
layers. Helpers polymorphic in this class can use getState and runQuery
without committing to either of those layers.
Associated Types
type SpockConn (m :: Type -> Type) Source #
type SpockState (m :: Type -> Type) Source #
type SpockSession (m :: Type -> Type) Source #
Methods
runQuery :: (SpockConn m -> IO a) -> m a Source #
Give you access to a database connectin from the connection pool. The connection is released back to the pool once the function terminates.
getState :: m (SpockState m) Source #
Read the application's state. If you wish to have mutable state, you could
use a TVar from the STM packge.
getSessMgr :: m (SpockSessionManager (SpockConn m) (SpockSession m) (SpockState m)) Source #
Get the session manager
getSpockCfg :: m (SpockCfg (SpockConn m) (SpockSession m) (SpockState m)) Source #
Get the Spock configuration
Instances
| MonadTrans t => HasSpock (t (WebStateM conn sess st)) Source # | |||||||||||||
Defined in Web.Spock.Internal.Monad Associated Types
Methods runQuery :: (SpockConn (t (WebStateM conn sess st)) -> IO a) -> t (WebStateM conn sess st) a Source # getState :: t (WebStateM conn sess st) (SpockState (t (WebStateM conn sess st))) Source # getSessMgr :: t (WebStateM conn sess st) (SpockSessionManager (SpockConn (t (WebStateM conn sess st))) (SpockSession (t (WebStateM conn sess st))) (SpockState (t (WebStateM conn sess st)))) Source # getSpockCfg :: t (WebStateM conn sess st) (SpockCfg (SpockConn (t (WebStateM conn sess st))) (SpockSession (t (WebStateM conn sess st))) (SpockState (t (WebStateM conn sess st)))) Source # | |||||||||||||
| HasSpock (WebStateM conn sess st) Source # | |||||||||||||
Defined in Web.Spock.Internal.Monad Associated Types
Methods runQuery :: (SpockConn (WebStateM conn sess st) -> IO a) -> WebStateM conn sess st a Source # getState :: WebStateM conn sess st (SpockState (WebStateM conn sess st)) Source # getSessMgr :: WebStateM conn sess st (SpockSessionManager (SpockConn (WebStateM conn sess st)) (SpockSession (WebStateM conn sess st)) (SpockState (WebStateM conn sess st))) Source # getSpockCfg :: WebStateM conn sess st (SpockCfg (SpockConn (WebStateM conn sess st)) (SpockSession (WebStateM conn sess st)) (SpockState (WebStateM conn sess st))) Source # | |||||||||||||
data SessionManager (m :: Type -> Type) conn sess st Source #
module Web.Spock.SessionActions
getCsrfToken :: SpockActionCtx ctx conn sess st Text Source #
Get the CSRF token for the current user. This token must be sent on all non
GET requests via a post parameter or HTTP-Header if spc_csrfProtection is turned on.
See configuration SpockCfg documentation for more information
getClientCsrfToken :: SpockActionCtx ctx conn sess st (Maybe Text) Source #
Get the CSRF token sent by the client. You should not need to call this
manually if spc_csrfProtection is turned on.
csrfCheck :: SpockActionCtx ctx conn sess st () Source #
Check that the client sent a valid CSRF token. You should not need to call this
manually in non GET requests if spc_csrfProtection is turned on.
Accessing internals
type WebStateM conn sess st = WebStateT conn sess st (ResourceT IO) Source #
Shared application services over ResourceT IO. This is the base monad
underneath both route registration and request actions in full Spock.
Helpers here can use getState and runQuery, but have no request body,
response, hook context, or current visitor's session. Those require the
action layer. Lift such a helper into an action or registration block with
lift; use runSpockIO with an existing environment to run it from IO.
data WebStateT conn sess st (m :: Type -> Type) a Source #
Add the application's WebState environment to an underlying monad m.
conn, sess, and st select the connection, session value, and shared state
types; a is the computation's result. This is a reader of an existing
environment, not a mutable state transformer. Put an IORef or TVar in
st when shared state needs to change, with suitable synchronization.
Applications normally use WebStateM, the resource-managed IO specialization.
Instances
| MonadBaseControl b m => MonadBaseControl b (WebStateT conn sess st m) Source # | |||||||||||||
| MonadBase b m => MonadBase b (WebStateT conn sess st m) Source # | |||||||||||||
Defined in Web.Spock.Internal.Types Methods liftBase :: b α -> WebStateT conn sess st m α | |||||||||||||
| MonadTrans t => HasSpock (t (WebStateM conn sess st)) Source # | |||||||||||||
Defined in Web.Spock.Internal.Monad Associated Types
Methods runQuery :: (SpockConn (t (WebStateM conn sess st)) -> IO a) -> t (WebStateM conn sess st) a Source # getState :: t (WebStateM conn sess st) (SpockState (t (WebStateM conn sess st))) Source # getSessMgr :: t (WebStateM conn sess st) (SpockSessionManager (SpockConn (t (WebStateM conn sess st))) (SpockSession (t (WebStateM conn sess st))) (SpockState (t (WebStateM conn sess st)))) Source # getSpockCfg :: t (WebStateM conn sess st) (SpockCfg (SpockConn (t (WebStateM conn sess st))) (SpockSession (t (WebStateM conn sess st))) (SpockState (t (WebStateM conn sess st)))) Source # | |||||||||||||
| HasSpock (WebStateM conn sess st) Source # | |||||||||||||
Defined in Web.Spock.Internal.Monad Associated Types
Methods runQuery :: (SpockConn (WebStateM conn sess st) -> IO a) -> WebStateM conn sess st a Source # getState :: WebStateM conn sess st (SpockState (WebStateM conn sess st)) Source # getSessMgr :: WebStateM conn sess st (SpockSessionManager (SpockConn (WebStateM conn sess st)) (SpockSession (WebStateM conn sess st)) (SpockState (WebStateM conn sess st))) Source # getSpockCfg :: WebStateM conn sess st (SpockCfg (SpockConn (WebStateM conn sess st)) (SpockSession (WebStateM conn sess st)) (SpockState (WebStateM conn sess st))) Source # | |||||||||||||
| MonadTransControl (WebStateT conn sess st) Source # | |||||||||||||
| MonadTrans (WebStateT conn sess st) Source # | |||||||||||||
Defined in Web.Spock.Internal.Types | |||||||||||||
| Monad m => MonadReader (WebState conn sess st) (WebStateT conn sess st m) Source # | |||||||||||||
| Applicative m => Applicative (WebStateT conn sess st m) Source # | |||||||||||||
Defined in Web.Spock.Internal.Types Methods pure :: a -> WebStateT conn sess st m a (<*>) :: WebStateT conn sess st m (a -> b) -> WebStateT conn sess st m a -> WebStateT conn sess st m b liftA2 :: (a -> b -> c) -> WebStateT conn sess st m a -> WebStateT conn sess st m b -> WebStateT conn sess st m c (*>) :: WebStateT conn sess st m a -> WebStateT conn sess st m b -> WebStateT conn sess st m b (<*) :: WebStateT conn sess st m a -> WebStateT conn sess st m b -> WebStateT conn sess st m a | |||||||||||||
| Functor m => Functor (WebStateT conn sess st m) Source # | |||||||||||||
Defined in Web.Spock.Internal.Types | |||||||||||||
| Monad m => Monad (WebStateT conn sess st m) Source # | |||||||||||||
| MonadIO m => MonadIO (WebStateT conn sess st m) Source # | |||||||||||||
Defined in Web.Spock.Internal.Types | |||||||||||||
| type SpockConn (t (WebStateM conn sess st)) Source # | |||||||||||||
Defined in Web.Spock.Internal.Monad | |||||||||||||
| type SpockSession (t (WebStateM conn sess st)) Source # | |||||||||||||
Defined in Web.Spock.Internal.Monad | |||||||||||||
| type SpockState (t (WebStateM conn sess st)) Source # | |||||||||||||
Defined in Web.Spock.Internal.Monad | |||||||||||||
| type SpockConn (WebStateM conn sess st) Source # | |||||||||||||
Defined in Web.Spock.Internal.Monad | |||||||||||||
| type SpockSession (WebStateM conn sess st) Source # | |||||||||||||
Defined in Web.Spock.Internal.Monad | |||||||||||||
| type SpockState (WebStateM conn sess st) Source # | |||||||||||||
Defined in Web.Spock.Internal.Monad | |||||||||||||
| type StT (WebStateT conn sess st) a Source # | |||||||||||||
Defined in Web.Spock.Internal.Types | |||||||||||||
| type StM (WebStateT conn sess st m) a Source # | |||||||||||||
Defined in Web.Spock.Internal.Types | |||||||||||||
data WebState conn sess st Source #
The application environment: connection pool, session manager, configuration, and shared state. It does not contain a particular request.
getSpockHeart :: MonadTrans t => t (WebStateM conn sess st) (WebState conn sess st) Source #
Read the heart of Spock. This is useful if you want to construct your own
monads that work with runQuery and getState using runSpockIO
getSpockPool :: MonadTrans t => t (WebStateM conn sess st) (Pool conn) Source #
Read the connection pool of Spock. This is useful if you want to construct your own
monads that work with runQuery and getState using runSpockIO