Spock
Safe HaskellNone
LanguageHaskell2010

Web.Spock.Config

Synopsis

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 #

An opt-in configuration for HTTPS browser applications: on-demand sessions, CSRF checks, and Secure, HttpOnly, SameSite=Lax browser-session cookies. For local HTTP development, explicitly override cs_secure to False.

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.

Instances

Instances details
Eq SlashPolicy  
Instance details

Defined in Web.Routing.SafeRouting

Methods

(==) :: SlashPolicy -> SlashPolicy -> Bool

(/=) :: SlashPolicy -> SlashPolicy -> Bool

Read SlashPolicy  
Instance details

Defined in Web.Routing.SafeRouting

Methods

readsPrec :: Int -> ReadS SlashPolicy

readList :: ReadS [SlashPolicy]

readPrec :: ReadPrec SlashPolicy

readListPrec :: ReadPrec [SlashPolicy]

Show SlashPolicy  
Instance details

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 

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

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.

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

data SessionMode Source #

On-demand sessions are loaded only by session actions (including CSRF checks). Disabled sessions leave database pooling and application state usable.

Instances

Instances details
Eq SessionMode Source # 
Instance details

Defined in Web.Spock.Internal.Types

Methods

(==) :: SessionMode -> SessionMode -> Bool

(/=) :: SessionMode -> SessionMode -> Bool

Show SessionMode Source # 
Instance details

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.

Instances

Instances details
Eq SessionError Source # 
Instance details

Defined in Web.Spock.Internal.Types

Methods

(==) :: SessionError -> SessionError -> Bool

(/=) :: SessionError -> SessionError -> Bool

Exception SessionError Source # 
Instance details

Defined in Web.Spock.Internal.Types

Methods

toException :: SessionError -> SomeException

fromException :: SomeException -> Maybe SessionError

displayException :: SessionError -> String

backtraceDesired :: SessionError -> Bool

Show SessionError Source # 
Instance details

Defined in Web.Spock.Internal.Types

Methods

showsPrec :: Int -> SessionError -> ShowS

show :: SessionError -> String

showList :: [SessionError] -> ShowS

data CookieSettings #

Cookie settings

Constructors

CookieSettings 

Fields

data SameSite #

Instances

Instances details
Eq SameSite  
Instance details

Defined in Web.Spock.Internal.Cookies

Methods

(==) :: SameSite -> SameSite -> Bool

(/=) :: SameSite -> SameSite -> Bool

Show SameSite  
Instance details

Defined in Web.Spock.Internal.Cookies

Methods

showsPrec :: Int -> SameSite -> ShowS

show :: SameSite -> String

showList :: [SameSite] -> ShowS

data CookieEOL #

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

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