Copyright | (c) Frederick Pringle 2024 |
---|---|
License | BSD-3-Clause |
Maintainer | freddyjepringle@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
The Body
type lets us represent HTTP bodies that may have interpretations as several different types.
Synopsis
- data Body
- noBody :: Body
- oneType :: forall a. Typeable a => Body
- manyTypes :: forall as. AllTypeable as => Body
- allOf :: forall as. AllTypeable as => Body
- oneOf :: forall as. AllTypeable as => Body
Documentation
A more expressive sum-type than just a list. This can be useful in situations where a body (request or response) may have several interpretations.
For example, the UVerb
combinator lets us represent an endpoint that may return one of
several types: hence the _routeResponseType
field needs to be able to contain
several TypeRep
s as a disjunction.
On the other hand, if multiple ReqBody'
s are chained together with :>
, the resulting
type's HasServer
instance would try to parse the request body as all of the relevant types. In this
case the _routeRequestBody
field needs to be able to contain several TypeRep
s
as a conjunction.
oneType :: forall a. Typeable a => Body Source #
The request/response body can only be of one type. Equivalent to a single
.ReqBody
_ a
manyTypes :: forall as. AllTypeable as => Body Source #
allOf :: forall as. AllTypeable as => Body Source #