Copyright | (c) Ben Weitzman 2018 |
---|---|
License | MIT |
Maintainer | ben@costarastrolgoy.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Http v
- get :: Member Http r => String -> Eff r (Response ByteString)
- getJSON :: (FromJSON a, Member Http r) => String -> Eff r a
- post :: Member Http r => String -> RequestBody -> Eff r (Response ByteString)
- postJSON :: (FromJSON resp, ToJSON req, Member Http r) => String -> req -> Eff r resp
- doRequest :: Member Http r => Request -> Eff r (Response ByteString)
- request :: Member Http r => Method -> RequestHeaders -> String -> Maybe RequestBody -> Eff r (Response ByteString)
- requestJSON :: (FromJSON resp, ToJSON req, Member Http r) => Method -> RequestHeaders -> String -> Maybe req -> Eff r resp
- data HttpException
- newtype JSONParseError = JSONParseError String
- runHttp :: forall r w. (Member IO r, Member (Error HttpException) r, Member (Error JSONParseError) r) => Manager -> Eff (Http ': r) w -> Eff r w
- mockHttp :: Eff (Http ': r) w -> (Request -> Response ByteString) -> Eff r w
- staticHttpMock :: Eff (Http ': r) w -> Map (Method, ByteString) (Status, ByteString) -> Eff r w
Documentation
getJSON :: (FromJSON a, Member Http r) => String -> Eff r a Source #
Make a GET request that expects a JSON response
post :: Member Http r => String -> RequestBody -> Eff r (Response ByteString) Source #
Make a POST request
postJSON :: (FromJSON resp, ToJSON req, Member Http r) => String -> req -> Eff r resp Source #
Make a POST request with a JSON body and response
doRequest :: Member Http r => Request -> Eff r (Response ByteString) Source #
Low level function for making an http request
request :: Member Http r => Method -> RequestHeaders -> String -> Maybe RequestBody -> Eff r (Response ByteString) Source #
Make an HTTP request
requestJSON :: (FromJSON resp, ToJSON req, Member Http r) => Method -> RequestHeaders -> String -> Maybe req -> Eff r resp Source #
Make an HTTP request using JSON for the body and response
data HttpException #
An exception which may be generated by this library
Since: http-client-0.5.0
Instances
Show HttpException | |
Defined in Network.HTTP.Client.Types showsPrec :: Int -> HttpException -> ShowS # show :: HttpException -> String # showList :: [HttpException] -> ShowS # | |
Exception HttpException | |
Defined in Network.HTTP.Client.Types |
newtype JSONParseError Source #
An error that an http response failed to parse
Instances
Show JSONParseError Source # | |
Defined in Control.Monad.Freer.Http showsPrec :: Int -> JSONParseError -> ShowS # show :: JSONParseError -> String # showList :: [JSONParseError] -> ShowS # |
runHttp :: forall r w. (Member IO r, Member (Error HttpException) r, Member (Error JSONParseError) r) => Manager -> Eff (Http ': r) w -> Eff r w Source #
mockHttp :: Eff (Http ': r) w -> (Request -> Response ByteString) -> Eff r w Source #
Interpret Http
using a pure function
staticHttpMock :: Eff (Http ': r) w -> Map (Method, ByteString) (Status, ByteString) -> Eff r w Source #
Interpret Http
using a static map. Will return a 404 if the method/path are not found in the map