snaplet-sqlite-simple-jwt-auth-0.1.0.0: Snaplet for JWT authentication with snaplet-sqlite-simple

Safe HaskellNone
LanguageHaskell2010

Snap.Snaplet.SqliteSimple.JwtAuth.Util

Synopsis

Documentation

finishEarly :: MonadSnap m => Int -> ByteString -> m b Source #

Discard anything after this and return given status code to HTTP client immediately.

writeJSON :: (MonadSnap m, ToJSON a) => a -> m () Source #

reqJSON :: (MonadSnap m, FromJSON b) => m b Source #

Demand the presence of JSON in the body assuming it is not larger than 50000 bytes.

reqBoundedJSON Source #

Arguments

:: (MonadSnap m, FromJSON a) 
=> Int64

Maximum size in bytes

-> m a 

Demand the presence of JSON in the body with a size up to N bytes. If parsing fails for any reson, request is terminated early and a server error is returned.

getBoundedJSON Source #

Arguments

:: (MonadSnap m, FromJSON a) 
=> Int64

Maximum size in bytes

-> m (Either String a) 

Parse request body into JSON or return an error string.

getKey Source #

Arguments

:: FilePath

File name where key is stored.

-> IO ByteString

The actual key.

Get a key from the given text file.

If the file does not exist, a random key will be generated and stored in that file.

This code is borrowed from the clientsession package but it uses a different signature. We just need the raw ByteString.