Spock-0.11.0.0: Another Haskell web framework for rapid development

Safe HaskellNone
LanguageHaskell98

Web.Spock.Config

Contents

Synopsis

Documentation

data SpockCfg conn sess st Source

Spock configuration, use defaultSpockCfg and change single values if needed

Constructors

SpockCfg 

Fields

spc_initialState :: st

initial application global state

spc_database :: PoolOrConn conn

See PoolOrConn

spc_sessionCfg :: SessionCfg conn sess st

See SessionCfg

spc_maxRequestSize :: Maybe Word64

Maximum request size in bytes. Nothing means no limit. Defaults to 5 MB in defaultSpockCfg.

spc_errorHandler :: Status -> ActionCtxT () IO ()

Custom error handlers for implicit errors such as not matching routes or exceptions during a request handler run.

spc_csrfProtection :: Bool

When set to true, all non GET request will require either an HTTP-Header spc_csrfHeaderName or a POST-Parameter spc_csrfPostName to be set to the value aquired by getCsrfToken

spc_csrfHeaderName :: Text

see spc_csrfHeaderName

spc_csrfPostName :: Text

see spc_csrfPostName

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

Constructors

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.

Constructors

ConnBuilder 

data PoolCfg Source

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

Constructors

SessionCfg 

Fields

sc_cookieName :: Text

name of the client side cookie

sc_sessionTTL :: NominalDiffTime

how long shoud a client session live

sc_sessionIdEntropy :: Int

entropy of the session id sent to the client

sc_sessionExpandTTL :: Bool

if this is true, every page reload will renew the session time to live counter

sc_emptySession :: a

initial session for visitors

sc_store :: SessionStoreInstance (Session conn a st)

storage interface for sessions

sc_housekeepingInterval :: NominalDiffTime

how often should the session manager check for dangeling dead sessions

sc_hooks :: SessionHooks a

hooks into the session manager

data SessionHooks a Source

Hook into the session manager to trigger custom behavior

Constructors

SessionHooks 

Fields

sh_removed :: HashMap SessionId a -> IO ()
 

data SessionStore sess tx Source

Constructors

SessionStore 

Fields

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 Source

Constructors

SessionStoreInstance :: forall sess tx. (Monad tx, Functor tx, Applicative tx) => SessionStore sess tx -> SessionStoreInstance sess