Safe Haskell | None |
---|---|
Language | Haskell2010 |
- finishEarly :: MonadSnap m => Int -> ByteString -> m b
- jsonResponse :: MonadSnap m => m ()
- writeJSON :: (MonadSnap m, ToJSON a) => a -> m ()
- reqJSON :: (MonadSnap m, FromJSON b) => m b
- reqBoundedJSON :: (MonadSnap m, FromJSON a) => Int64 -> m a
- getBoundedJSON :: (MonadSnap m, FromJSON a) => Int64 -> m (Either String a)
- getKey :: FilePath -> IO ByteString
Documentation
finishEarly :: MonadSnap m => Int -> ByteString -> m b Source #
Discard anything after this and return given status code to HTTP client immediately.
jsonResponse :: MonadSnap m => 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.
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.
Parse request body into JSON or return an error string.
:: 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.