magicbane-0.1.1: A web framework that integrates Servant, ClassyPrelude, EKG, fast-logger, wai-cli…

Safe HaskellNone
LanguageHaskell2010

Magicbane.Util

Description

Various useful functions.

Synopsis

Documentation

mergeVal :: Value -> Value -> Value Source #

Merges two JSON objects recursively. When the values are not objects, just returns the left one.

writeForm :: (ConvertibleStrings α Text, ConvertibleStrings β Text, ConvertibleStrings LByteString γ) => [(α, β)] -> γ Source #

Encodes key-value data as application/x-www-form-urlencoded.

readForm :: (ConvertibleStrings Text α, ConvertibleStrings Text β, ConvertibleStrings γ LByteString) => γ -> Maybe [(α, β)] Source #

Decodes key-value data from application/x-www-form-urlencoded.

formList :: Form -> [(Text, Text)] Source #

Reads a Servant incoming form as a list of key-value pairs (for use in FromForm instances).

formToObject :: [(Text, Text)] -> Value Source #

Converts a flat key-value form with keys in typical nesting syntax (e.g. "one[two][three]") to an Aeson Value with nesting (for use in FromForm instances).

parseUri :: ConvertibleStrings α String => α -> URI Source #

Parses any string into a URI.

slugify :: Text -> Text Source #

Prepares text for inclusion in a URL.

>>> :set -XOverloadedStrings
>>> slugify "Hello & World!"
"hello-and-world"

errText :: ServantErr -> LByteString -> ServantErr Source #

Creates a simple text/plain ServantErr.

throwErrText :: MonadError ServantErr μ => ServantErr -> LByteString -> μ α Source #

Creates and throws a simple text/plain ServantErr.