| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Servant.Hateoas.Resource
Synopsis
- class HasResource ct where
- class HasResource ct => ToResource ct api a where
- toResource :: Proxy ct -> Proxy api -> a -> Resource ct a
- data HRel = HRel {}
- class Related a where
- class BuildRels api rs a where
- selfLink :: forall api a id. (Related a, HasField (IdSelName a) a id, IsElem (GetOneApi a) api, HasLink (GetOneApi a), MkLink (GetOneApi a) Link ~ (id -> Link)) => Proxy api -> a -> (String, Link)
- relatedLinks :: forall api a. (Related a, BuildRels api (Relations a) a) => Proxy api -> a -> [(String, Link)]
- defaultLinks :: forall api a id. (Related a, HasField (IdSelName a) a id, IsElem (GetOneApi a) api, HasLink (GetOneApi a), MkLink (GetOneApi a) Link ~ (id -> Link), BuildRels api (Relations a) a) => Proxy api -> a -> [(String, Link)]
Resource
class HasResource ct Source #
Class that indicates that a Content-Type has a specific Resource-Representation.
class HasResource ct => ToResource ct api a where Source #
Class for converting values of a to their respective Resource-Representation.
Methods
toResource :: Proxy ct -> Proxy api -> a -> Resource ct a Source #
Converts a value into it's Resource-Representation.
Hypermedia-Relations
Type
Data-Kind for Hypermedia-Relations.
Constructors
| HRel | |
Class
Types that have Hypermedia-Relations.
Associated Types
type IdSelName a :: Symbol Source #
Name of the record selector that holds the resources identifier
type GetOneApi a :: Type Source #
Servant-Endpoint for retrieving one a by its identifier
type CollectionName a :: Symbol Source #
Name for collected values
type CollectionName a = "items"
type Relations a :: [HRel] Source #
List of all relations a has
Construction
class BuildRels api rs a where Source #
Class for deriving Hypermedia-Relations for types.
selfLink :: forall api a id. (Related a, HasField (IdSelName a) a id, IsElem (GetOneApi a) api, HasLink (GetOneApi a), MkLink (GetOneApi a) Link ~ (id -> Link)) => Proxy api -> a -> (String, Link) Source #
Generates the pair ("self", link) where link is the Link to a itself.
relatedLinks :: forall api a. (Related a, BuildRels api (Relations a) a) => Proxy api -> a -> [(String, Link)] Source #
Generates pairs (rel, link) for all related resources as defined with Relations.
defaultLinks :: forall api a id. (Related a, HasField (IdSelName a) a id, IsElem (GetOneApi a) api, HasLink (GetOneApi a), MkLink (GetOneApi a) Link ~ (id -> Link), BuildRels api (Relations a) a) => Proxy api -> a -> [(String, Link)] Source #
Generate Hypermedia-Links by default.
defaultLinks api x = selfLink api x : relatedLinks api x