Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data QueryString
- data DeepQuery (sym :: Symbol) (a :: Type)
- class FromDeepQuery a where
- 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 :: Type) 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")'
Instances
FromHttpApiData a => FromDeepQuery (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