servant-auth-token-0.3.2.0: Servant based API and server for token based authorisation

Copyright(c) Anton Gushcha, 2016
LicenseMIT
Maintainerncrashed@gmail.com
Stabilityexperimental
PortabilityPortable
Safe HaskellNone
LanguageHaskell2010

Servant.Server.Auth.Token.Monad

Description

 

Synopsis

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.

Constructors

AuthHandler 

Fields

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