Copyright | (c) Anton Gushcha, 2016 |
---|---|
License | MIT |
Maintainer | ncrashed@gmail.com |
Stability | experimental |
Portability | Portable |
Safe Haskell | None |
Language | Haskell2010 |
- newtype AuthHandler a = AuthHandler {}
- require :: ByteString -> Maybe a -> AuthHandler a
- getConfig :: AuthHandler AuthConfig
- getsConfig :: (AuthConfig -> a) -> AuthHandler a
- runDB404 :: ByteString -> SqlPersistT IO (Maybe a) -> AuthHandler a
Documentation
newtype AuthHandler a Source
This type represents the effects we want to have for our application.
We wrap the standard Servant monad with 'ReaderT Config', which gives us
access to the application configuration using the MonadReader
interface's ask
function.
By encapsulating the effects in our newtype, we can add layers to the monad stack without having to modify code that uses the current layout.
require :: ByteString -> Maybe a -> AuthHandler a Source
If the value is Nothing
, throw 400 response
getConfig :: AuthHandler AuthConfig Source
Getting config from global state
getsConfig :: (AuthConfig -> a) -> AuthHandler a Source
Getting config part from global state
runDB404 :: ByteString -> SqlPersistT IO (Maybe a) -> AuthHandler a Source
Run RDBMS operation and throw 404 (not found) error if
the second arg returns Nothing