tsweb-0.1.0.0: An API binding Web.Spock to Database.Beam

Safe HaskellNone
LanguageHaskell2010

TsWeb.Session

Description

This provides one essential function, patchConfig to replace Spock's default in-RAM session implementation with a Beam/postgres one.

Synopsis

Documentation

patchConfig :: (FromBackendRow Postgres (sessdata Identity), Beamable sessdata, Typeable sessdata, Database Postgres db, UserData (sessdata Identity), FieldsFulfillConstraint (HasSqlValueSyntax PgValueSyntax) sessdata) => DatabaseEntity Postgres db (TableEntity (SessionT sessdata)) -> Pool ReadOnlyConn -> Pool ReadWriteConn -> SpockCfg conn (sessdata Identity) st -> SpockCfg conn (sessdata Identity) st Source #

Update a spock configuration stanza to replace its default session with one backed by postgres. This will typically be used like so:

 spockCfg <-
   patchConfig (_dbSession db) ropool rwpool $
   defaultSpockCfg sess PCNoDatabase ()
 runSpock port (spock spockCfg routes)
 where
   sess = ...
   routes = ...

class UserData c where Source #

Typeclass for user-supplied data. We really just need to know whether the user has set a remember-me indicator upon login so that the session's lifespan can be intelligently controlled. If your session never needs to be remembers, then rememberMe = const False should suffice.

Methods

rememberMe :: c -> Bool Source #

Should the associated session be stored permanently?

Instances
UserData Users Source # 
Instance details

Defined in TsWeb.Tables.Session.Test