servant-lucid-0.8.1: Servant support for lucid

Safe HaskellNone
LanguageHaskell2010

Lucid.Servant

Description

Some helper functions for creating values in lucid DSLs that work with servant.

Synopsis

Documentation

safeHref_ :: (IsElem endpoint api, HasLink endpoint) => Text -> Proxy api -> Proxy endpoint -> MkLink endpoint Attribute Source #

safeLink variant which creates lucid's Attribute given base url.

>>> type API = "path" :> Get '[JSON] Int
>>> let api = Proxy :: Proxy API
>>> safeHref_ "" api api
Attribute "href" "path"
>>> safeHref_ "/" api api
Attribute "href" "/path"
>>> safeHref_ "http://example.com" api api
Attribute "href" "http://example.com/path"
>>> safeHref_ "http://example.com/" api api
Attribute "href" "http://example.com/path"

safeAbsHref_ :: (IsElem endpoint api, HasLink endpoint) => Proxy api -> Proxy endpoint -> MkLink endpoint Attribute Source #

safeLink "/"

safeRelHref_ :: (IsElem endpoint api, HasLink endpoint) => Proxy api -> Proxy endpoint -> MkLink endpoint Attribute Source #

safeLink ""

linkHref_ :: Text -> Link -> Attribute Source #

Create an href attribute from a Link, with given base url.

"servant" ensures that any Link is valid within an API. This function ensures it is possible to navigate to that endpoint from a page which shares a root with that API.

linkAbsHref_ :: Link -> Attribute Source #

Create an href attribute from a Link, with leading /.

"servant" ensures that any Link is valid within an API. This function ensures it is possible to navigate to that endpoint from a page which shares a root with that API.

linkRelHref_ :: Link -> Attribute Source #

Create an href attribute from a Link, as a relative link.

"servant" ensures that any Link is valid within an API. Use this function if a relative link (no leading /) is required.