Copyright | Allele Dev 2015 |
---|---|
License | BSD-3 |
Maintainer | allele.dev@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Network.Wai.RequestSpec
Contents
Description
- data Result a
- data P a
- parse :: (a -> P b) -> a -> Result b
- parseMaybe :: (a -> P b) -> a -> Maybe b
- parseEither :: (a -> P b) -> a -> Either Error b
- (<?>) :: P a -> Text -> P a
- freeform :: Text -> P a
- malformed :: Reason -> Text -> P a
- missing :: Loc -> P a
- data Loc
- type Reason = Text
- data Error
- toEnv :: Request -> Env
- toEnvWithForm :: Request -> [(Text, Text)] -> Env
- toEnvRaw :: Request -> ByteString -> Env
- data Env
- class FromEnv a where
- intQ :: (Read a, Integral a) => Text -> Env -> P a
- boolQ :: Text -> Env -> P Bool
- floatQ :: (Read a, Fractional a) => Text -> Env -> P a
- textQ :: Text -> Env -> P Text
- bytesQ :: (Text -> ByteString) -> Text -> Env -> P ByteString
- intQM :: (Read a, Integral a) => Text -> Env -> P (Maybe a)
- floatQM :: (Read a, Fractional a) => Text -> Env -> P (Maybe a)
- textQM :: Text -> Env -> P (Maybe Text)
- bytesQM :: (Text -> ByteString) -> Text -> Env -> P (Maybe ByteString)
- intF :: (Read a, Integral a) => Text -> Env -> P a
- boolF :: Text -> Env -> P Bool
- floatF :: (Read a, Fractional a) => Text -> Env -> P a
- textF :: Text -> Env -> P Text
- bytesF :: (Text -> ByteString) -> Text -> Env -> P ByteString
- intFM :: (Read a, Integral a) => Text -> Env -> P (Maybe a)
- floatFM :: (Read a, Fractional a) => Text -> Env -> P (Maybe a)
- textFM :: Text -> Env -> P (Maybe Text)
- bytesFM :: (Text -> ByteString) -> Text -> Env -> P (Maybe ByteString)
- intH :: (Integral a, Read a) => CI Text -> Env -> P a
- boolH :: CI Text -> Env -> P Bool
- floatH :: (Fractional a, Read a) => CI Text -> Env -> P a
- textH :: CI Text -> Env -> P Text
- bytesH :: (Text -> ByteString) -> CI Text -> Env -> P ByteString
- intHM :: (Integral a, Read a) => CI Text -> Env -> P (Maybe a)
- floatHM :: (Fractional a, Read a) => CI Text -> Env -> P (Maybe a)
- textHM :: CI Text -> Env -> P (Maybe Text)
- bytesHM :: (Text -> ByteString) -> CI Text -> Env -> P (Maybe ByteString)
- choice :: [P a] -> P a
Primitive parsing data types
Primitive parsing functions
parseMaybe :: (a -> P b) -> a -> Maybe b #
parseEither :: (a -> P b) -> a -> Either Error b #
Error generation and parser annotation
Error types
Generating parsing environment
Construct an Env without parsing any form parameters This is ideal if you're not consuming any form data.
toEnvWithForm :: Request -> [(Text, Text)] -> Env #
Construct an Env from a Request and an association list of form parameters
If a framework exposes parameters in this fashion (Spock, Scotty),
use this over toEnvRaw
. It's likely the framework consumes the
request body when data is sent along using content-type
'application/x-www-form-urlencoded'
toEnvRaw :: Request -> ByteString -> Env #
Expects form data via request body ByteString This is appropriate if you're programming with raw Network.Wai NOTE: if you're expecting form data, and the form data is in an invalid format this will happily construct an Env with empty form data
Parser driving type class
Allows for the parsing of a data type a
from an Env
Minimal complete definition
Derived combinators, query parameters
bytesQ :: (Text -> ByteString) -> Text -> Env -> P ByteString #
Require a parameter as bytes, applying the encoding function f
bytesQM :: (Text -> ByteString) -> Text -> Env -> P (Maybe ByteString) #
Optional header as bytes, applying the encoding function f
Derived combinators, form parameters
bytesF :: (Text -> ByteString) -> Text -> Env -> P ByteString #
Require a parameter as bytes, applying the encoding function f
bytesFM :: (Text -> ByteString) -> Text -> Env -> P (Maybe ByteString) #
Optional header as bytes, applying the encoding function f
Derived combinators, headers
bytesH :: (Text -> ByteString) -> CI Text -> Env -> P ByteString #
Require a header as bytes, applying the encoding function f
bytesHM :: (Text -> ByteString) -> CI Text -> Env -> P (Maybe ByteString) #
Optional header as bytes, applying the encoding function f