freer-simple-http-0.1.0.0: Make HTTP requests with freer-simple!

Copyright(c) Ben Weitzman 2018
LicenseMIT
Maintainerben@costarastrolgoy.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Freer.Http

Description

 
Synopsis

Documentation

data Http v Source #

The Http effect is for making http requests

get :: Member Http r => String -> Eff r (Response ByteString) Source #

Make a GET request

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

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

newtype JSONParseError Source #

An error that an http response failed to parse

Constructors

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 Source #

Interpret Http using IO and the 'http-client' library

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