Copyright | (c) Raghu Kaippully 2020 |
---|---|
License | MPL-2.0 |
Maintainer | rkaippully@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Middlewares related to HTTP body.
Synopsis
- data JSONRequestBody (t :: Type)
- jsonRequestBody :: forall t m req a. (FromJSON t, MonadRouter m, MonadIO m) => RequestMiddleware' m req (JSONRequestBody t ': req) a
- jsonResponseBody :: (ToJSON t, Monad m) => ResponseMiddleware' m req t ByteString
Documentation
data JSONRequestBody (t :: Type) Source #
A Trait
for converting a JSON request body into a value.
Instances
(FromJSON t, MonadIO m) => Trait (JSONRequestBody t :: Type) Request m Source # | |
Defined in WebGear.Middlewares.Body type Attribute (JSONRequestBody t) Request Source # type Absence (JSONRequestBody t) Request Source # toAttribute :: Request -> m (Result (JSONRequestBody t) Request) Source # | |
type Attribute (JSONRequestBody t :: Type) Request Source # | |
Defined in WebGear.Middlewares.Body | |
type Absence (JSONRequestBody t :: Type) Request Source # | |
Defined in WebGear.Middlewares.Body |
jsonRequestBody :: forall t m req a. (FromJSON t, MonadRouter m, MonadIO m) => RequestMiddleware' m req (JSONRequestBody t ': req) a Source #
jsonResponseBody :: (ToJSON t, Monad m) => ResponseMiddleware' m req t ByteString Source #
A middleware that converts the response that has a ToJSON
instance to a ByteString
response.
This will also set the "Content-Type" header of the response to "application/json".
Usage for a type t
which has a ToJSON
instance:
jsonResponseBody @t handler