network-api-support-0.3.4: Toolkit for building http client libraries over Network.Http.Conduit

Safe HaskellNone
LanguageHaskell98

Network.Api.Support.Response

Synopsis

Documentation

type Responder a = Request -> Response ByteString -> a Source #

Response handler.

data JsonResult a Source #

Wrap up json parse and decode errors.

Instances
Monad JsonResult Source # 
Instance details

Defined in Network.Api.Support.Response

Methods

(>>=) :: JsonResult a -> (a -> JsonResult b) -> JsonResult b #

(>>) :: JsonResult a -> JsonResult b -> JsonResult b #

return :: a -> JsonResult a #

fail :: String -> JsonResult a #

Functor JsonResult Source # 
Instance details

Defined in Network.Api.Support.Response

Methods

fmap :: (a -> b) -> JsonResult a -> JsonResult b #

(<$) :: a -> JsonResult b -> JsonResult a #

Applicative JsonResult Source # 
Instance details

Defined in Network.Api.Support.Response

Methods

pure :: a -> JsonResult a #

(<*>) :: JsonResult (a -> b) -> JsonResult a -> JsonResult b #

liftA2 :: (a -> b -> c) -> JsonResult a -> JsonResult b -> JsonResult c #

(*>) :: JsonResult a -> JsonResult b -> JsonResult b #

(<*) :: JsonResult a -> JsonResult b -> JsonResult a #

Eq a => Eq (JsonResult a) Source # 
Instance details

Defined in Network.Api.Support.Response

Methods

(==) :: JsonResult a -> JsonResult a -> Bool #

(/=) :: JsonResult a -> JsonResult a -> Bool #

Show a => Show (JsonResult a) Source # 
Instance details

Defined in Network.Api.Support.Response

parseBody :: FromJSON a => ByteString -> JsonResult a Source #

Parse and decode body.

parseBodyWith :: FromJSON a => ByteString -> (Text -> b) -> (Text -> b) -> (a -> b) -> b Source #

Parse and decode body handling error cases and success case.

basicResponder :: (Int -> ByteString -> a) -> Responder a Source #

Lift function handling status code and body into a responder.