| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Web.Spock.Config
Synopsis
- 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_logError :: Text -> IO ()
- spc_logging :: Maybe LoggingConfig
- spc_slashPolicy :: SlashPolicy
- spc_csrfProtection :: Bool
- spc_csrfHeaderName :: Text
- spc_csrfPostName :: Text
- defaultSpockCfg :: sess -> PoolOrConn conn -> st -> IO (SpockCfg conn sess st)
- defaultBrowserSpockCfg :: sess -> PoolOrConn conn -> st -> IO (SpockCfg conn sess st)
- data SlashPolicy
- data PoolOrConn a where
- PCPool :: forall a. Pool a -> PoolOrConn a
- PCConn :: forall a. 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 {}
- data SessionBackend conn sess st
- = ServerSessions (ServerSessionCfg conn sess st)
- | ClientSessions (ClientSessionCfg sess)
- data ServerSessionCfg conn sess st = ServerSessionCfg {
- ssc_store :: SessionStoreInstance (Session conn sess st)
- ssc_housekeepingInterval :: NominalDiffTime
- ssc_hooks :: SessionHooks sess
- defaultServerSessionCfg :: SessionStoreInstance (Session conn sess st) -> ServerSessionCfg conn sess st
- data ClientSessionCfg sess = ClientSessionCfg {
- csc_codec :: ClientSessionCodec sess
- csc_maxCookieBytes :: Int
- csc_clock :: IO UTCTime
- data ClientSessionCodec sess = ClientSessionCodec {
- csc_encode :: forall conn st. Text -> Session conn sess st -> IO ByteString
- csc_decode :: forall conn st. Text -> ByteString -> IO (Maybe (Session conn sess st, Bool))
- defaultClientSessionCfg :: ClientSessionCodec sess -> ClientSessionCfg sess
- data SessionMode
- data SessionError
- data CookieSettings = CookieSettings {}
- data SameSite
- data CookieEOL
- defaultSessionHooks :: SessionHooks a
- data SessionHooks a = SessionHooks {
- sh_removed :: HashMap SessionId a -> IO ()
- data SessionStore sess (tx :: Type -> Type) = 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 :: Type -> Type). (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
Constructors
| SpockCfg | |
Fields
| |
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.
defaultBrowserSpockCfg :: sess -> PoolOrConn conn -> st -> IO (SpockCfg conn sess st) Source #
data SlashPolicy #
How empty path segments are treated. The compatibility default ignores every empty segment. Strict policies preserve internal and trailing slashes. Redirects are performed by the HTTP adapter, using strict registry matching.
Constructors
| IgnoreSlashes | |
| StrictSlashes | |
| RedirectTrailingSlashes |
Instances
| Eq SlashPolicy | |
Defined in Web.Routing.SafeRouting | |
| Read SlashPolicy | |
Defined in Web.Routing.SafeRouting Methods readsPrec :: Int -> ReadS SlashPolicy readList :: ReadS [SlashPolicy] readPrec :: ReadPrec SlashPolicy readListPrec :: ReadPrec [SlashPolicy] | |
| Show SlashPolicy | |
Defined in Web.Routing.SafeRouting Methods showsPrec :: Int -> SlashPolicy -> ShowS show :: SlashPolicy -> String showList :: [SlashPolicy] -> ShowS | |
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 :: forall a. Pool a -> PoolOrConn a | |
| PCConn :: forall a. ConnBuilder a -> PoolOrConn a | |
| PCNoDatabase :: PoolOrConn () |
data ConnBuilder a Source #
The ConnBuilder instructs Spock how to create or close a database connection.
Constructors
| ConnBuilder | |
Fields
| |
If Spock should take care of connection pooling, you need to configure it depending on what you need.
Constructors
| PoolCfg | |
Fields | |
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
| |
data SessionBackend conn sess st Source #
Select storage separately from the shared lifetime, cookie and mode options.
Constructors
| ServerSessions (ServerSessionCfg conn sess st) | |
| ClientSessions (ClientSessionCfg sess) |
data ServerSessionCfg conn sess st Source #
Store, sweep interval and removal hooks used only by server backends.
Customize the value returned by defaultServerSessionCfg.
Constructors
| ServerSessionCfg | |
Fields
| |
defaultServerSessionCfg :: SessionStoreInstance (Session conn sess st) -> ServerSessionCfg conn sess st Source #
data ClientSessionCfg sess Source #
Cookie backend settings. Use a maintained authenticated codec such as
Spock-session-cookie; plain JSON or unauthenticated encryption is unsafe.
Constructors
| ClientSessionCfg | |
Fields
| |
data ClientSessionCodec sess Source #
Trusted codec interface for backend packages. Encode must authenticate and encrypt the complete session, bound to the supplied cookie name. Decode must authenticate before returning data, and return Nothing for untrusted input. The Bool asks the manager to reissue a cookie after key or format rotation.
Constructors
| ClientSessionCodec | |
Fields
| |
defaultClientSessionCfg :: ClientSessionCodec sess -> ClientSessionCfg sess Source #
data SessionMode Source #
On-demand sessions are loaded only by session actions (including CSRF checks). Disabled sessions leave database pooling and application state usable.
Constructors
| SessionsAlways | |
| SessionsOnDemand | |
| SessionsDisabled |
Instances
| Eq SessionMode Source # | |
Defined in Web.Spock.Internal.Types | |
| Show SessionMode Source # | |
Defined in Web.Spock.Internal.Types Methods showsPrec :: Int -> SessionMode -> ShowS show :: SessionMode -> String showList :: [SessionMode] -> ShowS | |
data SessionError Source #
Invalid session configuration, unavailable capabilities or rejected writes.
Constructors
| SessionUseWhenDisabled | |
| CsrfRequiresSessions | |
| ServerSessionsRequired | |
| ClientSessionOutsideRequest | |
| ClientSessionCookieTooLarge | |
| InvalidClientSessionConfig |
Instances
| Eq SessionError Source # | |
Defined in Web.Spock.Internal.Types | |
| Exception SessionError Source # | |
Defined in Web.Spock.Internal.Types Methods toException :: SessionError -> SomeException fromException :: SomeException -> Maybe SessionError displayException :: SessionError -> String backtraceDesired :: SessionError -> Bool | |
| Show SessionError Source # | |
Defined in Web.Spock.Internal.Types Methods showsPrec :: Int -> SessionError -> ShowS show :: SessionError -> String showList :: [SessionError] -> ShowS | |
data CookieSettings #
Cookie settings
Constructors
| CookieSettings | |
Fields
| |
Constructors
| SameSiteLax | |
| SameSiteStrict | |
| SameSiteNone |
Setting cookie expiration
Constructors
| CookieValidUntil UTCTime | a point in time in UTC until the cookie is valid |
| CookieValidFor NominalDiffTime | a period (in seconds) for which the cookie is valid |
| CookieValidForSession | the cookie expires with the browser session |
| CookieValidForever | the cookie will have an expiration date in the far future |
defaultSessionHooks :: SessionHooks a Source #
NOP session hooks
data SessionHooks a Source #
Hook into the session manager to trigger custom behavior
Constructors
| SessionHooks | |
Fields
| |
data SessionStore sess (tx :: Type -> Type) Source #
Constructors
| SessionStore | |
Fields
| |
data SessionStoreInstance sess where Source #
Constructors
| SessionStoreInstance :: forall sess (tx :: Type -> Type). (Monad tx, Functor tx, Applicative tx) => SessionStore sess tx -> SessionStoreInstance sess |
newStmSessionStore :: IO (SessionStoreInstance (Session conn sess st)) Source #