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

Safe HaskellNone



Various useful functions and type definitions.



type Host = Header "Host" Text Source #

type WithLink α = Headers '[Header "Link" [HTTPLink]] α Source #

hPutStrLn :: MonadIO μ => Handle -> String -> μ () Source #

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 ByteString γ) => [(α, β)] -> γ Source #

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

readForm :: (ConvertibleStrings Text α, ConvertibleStrings Text β, ConvertibleStrings γ ByteString) => γ -> 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!"

errText :: ServantErr -> ByteString -> ServantErr Source #

Creates a simple text/plain ServantErr.

throwErrText :: MonadThrow μ => ServantErr -> ByteString -> μ α Source #

Creates and throws a simple text/plain ServantErr.