Copyright | (c) Will Sewell, 2015 |
---|---|
License | MIT |
Maintainer | [email protected] |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Network.Pusher.Internal.HTTP
Description
A layer on top of the HTTP functions in the Wreq library which lifts the return values to the typclasses we are using in this library. Non 200 responses are converted into MonadError errors.
- class Monad m => MonadHTTP m where
- httpLbs :: Request -> Manager -> m (Response ByteString)
- get :: (FromJSON a, Functor m, MonadError Text m, MonadHTTP m) => Manager -> ByteString -> [(ByteString, ByteString)] -> m a
- post :: (ToJSON a, Functor m, MonadError Text m, MonadHTTP m) => Manager -> ByteString -> [(ByteString, ByteString)] -> a -> m ()
Documentation
class Monad m => MonadHTTP m where Source
These functions essentially abstract the corresponding functions from the Wreq library.
Arguments
:: (FromJSON a, Functor m, MonadError Text m, MonadHTTP m) | |
=> Manager | |
-> ByteString | The API endpoint, for example http://api.pusherapp.com/apps/123/events |
-> [(ByteString, ByteString)] | List of query string parameters as key-value tuples |
-> m a | The body of the response |
Issue an HTTP GET request. On a 200 response, the response body is returned. On failure, an error will be thrown into the MonadError instance.
post :: (ToJSON a, Functor m, MonadError Text m, MonadHTTP m) => Manager -> ByteString -> [(ByteString, ByteString)] -> a -> m () Source
Issue an HTTP POST request.