Safe Haskell | None |
---|---|
Language | Haskell2010 |
Integrate Waargonaut with Servant, including support for the tagged typeclass encoder/decoder functionality.
Synopsis
- data WaargJSON t
Documentation
Replacement for JSON
that will use the relevant instances from
Waargonaut that are tagged with the type t
.
This allows you to have separate typeclass implementations for the same type for different routes and have it be evident in the types. Without the need for creating a 'newtype' for each one.
Where you would use JSON
to use aeson
for encoding or decoding, you use 'WaargJSON t', with
the t
denoting the tag type. Refer to the Waargonaut
package for more information about why this is so.
A hello world example:
>>>
-- GET /hello/world
>>>
-- returning a JSON encoded World value
>>>
data MyTag = MyTag
>>>
type MyApi = "hello" :> "world" :> Get '[WaargJSON MyTag] World
Instances
Accept (WaargJSON t :: Type) Source # | |
Defined in Servant.API.ContentTypes.Waargonaut | |
JsonEncode t a => MimeRender (WaargJSON t :: Type) a Source # | |
Defined in Servant.API.ContentTypes.Waargonaut mimeRender :: Proxy (WaargJSON t) -> a -> ByteString # | |
JsonDecode t a => MimeUnrender (WaargJSON t :: Type) a Source # | |
Defined in Servant.API.ContentTypes.Waargonaut mimeUnrender :: Proxy (WaargJSON t) -> ByteString -> Either String a # mimeUnrenderWithType :: Proxy (WaargJSON t) -> MediaType -> ByteString -> Either String a # |