Safe Haskell | None |
---|---|
Language | Haskell2010 |
Servant.API.QueryString
Synopsis
- data QueryString
- data DeepQuery (sym :: Symbol) a
- class FromDeepQuery a where
- fromDeepQuery :: [([Text], Maybe Text)] -> Either String a
- class ToDeepQuery a where
- toDeepQuery :: a -> [([Text], Maybe Text)]
- generateDeepParam :: Text -> ([Text], Maybe Text) -> (Text, Maybe Text)
Documentation
data QueryString Source #
Extract the whole query string from a request. This is useful for query strings
containing dynamic parameter names. For query strings with static parameter names,
QueryParam
is more suited.
Example:
>>>
-- /books?author=<author name>&year=<book year>
>>>
type MyApi = "books" :> QueryString :> Get '[JSON] [Book]
data DeepQuery (sym :: Symbol) a Source #
Extract an deep object from a query string.
Example:
>>>
-- /books?filter[author][name]=<author name>&filter[year]=<book year>
>>>
type MyApi = "books" :> DeepQuery "filter" BookQuery :> Get '[JSON] [Book]
class FromDeepQuery a where Source #
Extract a deep object from (possibly nested) query parameters.
a param like filter[a][b][c]=d
will be represented as
'(["a", "b", "c"], Just "d")'
. Note that a parameter with no
nested field is possible: filter=a
will be represented as
'([], Just "a")'
Methods
fromDeepQuery :: [([Text], Maybe Text)] -> Either String a Source #
Instances
FromHttpApiData a => FromDeepQuery (Map Text a) Source # | |
Defined in Servant.API.QueryString Methods fromDeepQuery :: [([Text], Maybe Text)] -> Either String (Map Text a) Source # |
class ToDeepQuery a where Source #
Generate query parameters from an object, using the deep object syntax.
A result of '(["a", "b", "c"], Just "d")'
attributed to the filter
parameter name will result in the following query parameter:
filter[a][b][c]=d
Methods
toDeepQuery :: a -> [([Text], Maybe Text)] Source #
generateDeepParam :: Text -> ([Text], Maybe Text) -> (Text, Maybe Text) Source #
Turn a nested path into a deep object query param
>>>
generateDeepParam "filter" (["a", "b", "c"], Just "d")
("filter[a][b][c]",Just "d")