Safe Haskell | None |
---|---|
Language | Haskell2010 |
DSL for parsing the request.
- type Parser = RequestParser
- fail :: Monad m => Text -> Parser m a
- try :: Monad m => Parser m a -> Parser m (Either Text a)
- segment :: (Monad m, LenientParser a) => Parser m a
- segmentWithParser :: Monad m => Parser a -> Parser m a
- segmentIs :: Monad m => Text -> Parser m ()
- noSegmentsLeft :: Monad m => Parser m ()
- query1 :: (Monad m, DefaultValue a) => Text -> Parser m a
- query2 :: (Monad m, DefaultValue a, DefaultValue b) => Text -> Text -> Parser m (a, b)
- query3 :: (Monad m, DefaultValue a, DefaultValue b, DefaultValue c) => Text -> Text -> Text -> Parser m (a, b, c)
- query4 :: (Monad m, DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d) => Text -> Text -> Text -> Text -> Parser m (a, b, c, d)
- query5 :: (Monad m, DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e) => Text -> Text -> Text -> Text -> Text -> Parser m (a, b, c, d, e)
- query6 :: (Monad m, DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e, DefaultValue f) => Text -> Text -> Text -> Text -> Text -> Text -> Parser m (a, b, c, d, e, f)
- query7 :: (Monad m, DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e, DefaultValue f, DefaultValue g) => Text -> Text -> Text -> Text -> Text -> Text -> Text -> Parser m (a, b, c, d, e, f, g)
- queryWithParser :: Monad m => Params a -> Parser m a
- method :: Monad m => Parser m ByteString
- methodIs :: Monad m => ByteString -> Parser m ()
- methodIsGet :: Monad m => Parser m ()
- methodIsPost :: Monad m => Parser m ()
- methodIsPut :: Monad m => Parser m ()
- methodIsDelete :: Monad m => Parser m ()
- methodIsHead :: Monad m => Parser m ()
- methodIsTrace :: Monad m => Parser m ()
- header :: Monad m => ByteString -> Parser m ByteString
- accepts :: Monad m => ByteString -> Parser m ()
- acceptsText :: Monad m => Parser m ()
- acceptsHTML :: Monad m => Parser m ()
- acceptsJSON :: Monad m => Parser m ()
- authorization :: Monad m => Parser m (Text, Text)
- body :: (MonadIO m, DefaultParser a) => Parser m a
- bodyWithParser :: MonadIO m => Parser a -> Parser m a
Documentation
type Parser = RequestParser Source #
Parser of an HTTP request. Analyzes its meta information, consumes the path segments and the body.
Errors
try :: Monad m => Parser m a -> Parser m (Either Text a) Source #
Try a parser, extracting the error as Either.
Path Segments
segment :: (Monad m, LenientParser a) => Parser m a Source #
Consume the next segment of the path with an implicit lenient Attoparsec parser.
segmentWithParser :: Monad m => Parser a -> Parser m a Source #
Consume the next segment of the path with an explicit Attoparsec parser.
segmentIs :: Monad m => Text -> Parser m () Source #
Consume the next segment if it matches the provided value and fail otherwise.
noSegmentsLeft :: Monad m => Parser m () Source #
Fail if there's any path segments left unconsumed.
Query
query1 :: (Monad m, DefaultValue a) => Text -> Parser m a Source #
Parse the query using implicit parsers by specifying the names of parameters.
query2 :: (Monad m, DefaultValue a, DefaultValue b) => Text -> Text -> Parser m (a, b) Source #
Parse the query using implicit parsers by specifying the names of parameters.
query3 :: (Monad m, DefaultValue a, DefaultValue b, DefaultValue c) => Text -> Text -> Text -> Parser m (a, b, c) Source #
Parse the query using implicit parsers by specifying the names of parameters.
query4 :: (Monad m, DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d) => Text -> Text -> Text -> Text -> Parser m (a, b, c, d) Source #
Parse the query using implicit parsers by specifying the names of parameters.
query5 :: (Monad m, DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e) => Text -> Text -> Text -> Text -> Text -> Parser m (a, b, c, d, e) Source #
Parse the query using implicit parsers by specifying the names of parameters.
query6 :: (Monad m, DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e, DefaultValue f) => Text -> Text -> Text -> Text -> Text -> Text -> Parser m (a, b, c, d, e, f) Source #
Parse the query using implicit parsers by specifying the names of parameters.
query7 :: (Monad m, DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e, DefaultValue f, DefaultValue g) => Text -> Text -> Text -> Text -> Text -> Text -> Text -> Parser m (a, b, c, d, e, f, g) Source #
Parse the query using implicit parsers by specifying the names of parameters.
queryWithParser :: Monad m => Params a -> Parser m a Source #
Parse the request query, i.e. the URL part that is between the "?" and "#" characters, with an explicitly specified parser.
Methods
methodIs :: Monad m => ByteString -> Parser m () Source #
Ensure that the method matches the provided value in lower-case.
Headers
header :: Monad m => ByteString -> Parser m ByteString Source #
Lookup a header by name in lower-case.
accepts :: Monad m => ByteString -> Parser m () Source #
Ensure that the request provides an Accept header, which includes the specified content type. Content type must be in lower-case.
authorization :: Monad m => Parser m (Text, Text) Source #
Parse the username and password from the basic authorization header.