Safe Haskell | None |
---|---|
Language | Haskell98 |
- data SpockCfg conn sess st = SpockCfg {
- spc_initialState :: st
- spc_database :: PoolOrConn conn
- spc_sessionCfg :: SessionCfg conn sess st
- spc_maxRequestSize :: Maybe Word64
- spc_errorHandler :: Status -> ActionCtxT () IO ()
- spc_csrfProtection :: Bool
- spc_csrfHeaderName :: Text
- spc_csrfPostName :: Text
- defaultSpockCfg :: sess -> PoolOrConn conn -> st -> IO (SpockCfg conn sess st)
- data PoolOrConn a where
- PCPool :: Pool a -> PoolOrConn a
- PCConn :: ConnBuilder a -> PoolOrConn a
- PCNoDatabase :: PoolOrConn ()
- data ConnBuilder a = ConnBuilder {
- cb_createConn :: IO a
- cb_destroyConn :: a -> IO ()
- cb_poolConfiguration :: PoolCfg
- data PoolCfg = PoolCfg {}
- defaultSessionCfg :: a -> IO (SessionCfg conn a st)
- data SessionCfg conn a st = SessionCfg {}
- defaultSessionHooks :: SessionHooks a
- data SessionHooks a = SessionHooks {
- sh_removed :: HashMap SessionId a -> IO ()
- data SessionStore sess tx = SessionStore {
- ss_runTx :: forall a. tx a -> IO a
- ss_loadSession :: SessionId -> tx (Maybe sess)
- ss_deleteSession :: SessionId -> tx ()
- ss_storeSession :: sess -> tx ()
- ss_toList :: tx [sess]
- ss_filterSessions :: (sess -> Bool) -> tx ()
- ss_mapSessions :: (sess -> tx sess) -> tx ()
- data SessionStoreInstance sess where
- SessionStoreInstance :: forall sess tx. (Monad tx, Functor tx, Applicative tx) => SessionStore sess tx -> SessionStoreInstance sess
- newStmSessionStore :: IO (SessionStoreInstance (Session conn sess st))
Documentation
data SpockCfg conn sess st Source #
Spock configuration, use defaultSpockCfg
and change single values if needed
SpockCfg | |
|
defaultSpockCfg :: sess -> PoolOrConn conn -> st -> IO (SpockCfg conn sess st) Source #
Spock configuration with reasonable defaults such as a basic error page and 5MB request body limit. IMPORTANT: CSRF Protection is turned off by default for now to not break any existing Spock applications. Consider turning it on manually as it will become the default in the future.
Database
data PoolOrConn a where Source #
You can feed Spock with either a connection pool, or instructions on how to build
a connection pool. See ConnBuilder
PCPool :: Pool a -> PoolOrConn a | |
PCConn :: ConnBuilder a -> PoolOrConn a | |
PCNoDatabase :: PoolOrConn () |
data ConnBuilder a Source #
The ConnBuilder instructs Spock how to create or close a database connection.
ConnBuilder | |
|
If Spock should take care of connection pooling, you need to configure it depending on what you need.
Sessions
defaultSessionCfg :: a -> IO (SessionCfg conn a st) Source #
Session configuration with reasonable defaults and an stm based session store
data SessionCfg conn a st Source #
Configuration for the session manager
SessionCfg | |
|
defaultSessionHooks :: SessionHooks a Source #
NOP session hooks
data SessionHooks a Source #
Hook into the session manager to trigger custom behavior
SessionHooks | |
|
data SessionStore sess tx Source #
SessionStore | |
|
data SessionStoreInstance sess where Source #
SessionStoreInstance :: forall sess tx. (Monad tx, Functor tx, Applicative tx) => SessionStore sess tx -> SessionStoreInstance sess |
newStmSessionStore :: IO (SessionStoreInstance (Session conn sess st)) Source #