servant-0.4.4.7: A family of combinators for defining webservices APIs

Safe HaskellSafe
LanguageHaskell2010

Servant.API.MatrixParam

Synopsis

Documentation

data MatrixFlag sym Source

Lookup a potentially value-less matrix string parameter with boolean semantics. If the param sym is there without any value, or if it's there with value "true" or "1", it's interpreted as True. Otherwise, it's interpreted as False.

Example:

>>> -- /books;published
>>> type MyApi = "books" :> MatrixFlag "published" :> Get '[JSON] [Book]

Instances

(KnownSymbol sym, HasLink k sub) => HasLink * ((:>) * k (MatrixFlag sym) sub) Source 
type MkLink * ((:>) * k (MatrixFlag sym) sub) = Bool -> MkLink k sub Source 

data MatrixParam sym a Source

Lookup the value associated to the sym matrix string parameter and try to extract it as a value of type a.

Example:

>>> -- /books;author=<author name>
>>> type MyApi = "books" :> MatrixParam "author" Text :> Get '[JSON] [Book]

Instances

(KnownSymbol sym, ToText v, HasLink k sub) => HasLink * ((:>) * k (MatrixParam * sym v) sub) Source 
type MkLink * ((:>) * k (MatrixParam * sym v) sub) = v -> MkLink k sub Source 

data MatrixParams sym a Source

Lookup the values associated to the sym matrix string parameter and try to extract it as a value of type [a]. This is typically meant to support matrix string parameters of the form param[]=val1;param[]=val2 and so on. Note that servant doesn't actually require the []s and will fetch the values just fine with param=val1;param=val2, too.

Example:

>>> -- /books;authors[]=<author1>;authors[]=<author2>;...
>>> type MyApi = "books" :> MatrixParams "authors" Text :> Get '[JSON] [Book]

Instances

(KnownSymbol sym, ToText v, HasLink k sub) => HasLink * ((:>) * k (MatrixParams * sym v) sub) Source 
type MkLink * ((:>) * k (MatrixParams * sym v) sub) = [v] -> MkLink k sub Source