magicbane-0.1.3: A web framework that integrates Servant, ClassyPrelude, EKG, fast-logger, wai-cli…

Safe HaskellNone
LanguageHaskell2010

Magicbane.HTTPClient

Contents

Description

Provides an HTTP(S) client via http-client(-tls) in a Magicbane app context. Also provides a simple composable interface for making arbitrary requests, based on http-client-conduit. That lets you plug stream parsers (e.g. html-conduit: 'performWithFn ($$ sinkDoc)') directly into the reading of the response body.

Synopsis

Documentation

runHTTP :: EitherT ε μ α -> μ (Either ε α) Source #

reqU :: MonadHTTP ψ μ => URI -> EitherT Text μ Request Source #

Creates a request from a URI.

reqS :: (MonadHTTP ψ μ, ConvertibleStrings σ String) => σ -> EitherT Text μ Request Source #

Creates a request from a string of any type, parsing it into a URI.

anyStatus :: MonadHTTP ψ μ => Request -> EitherT Text μ Request Source #

Configures the request to not throw errors on error status codes.

postForm :: MonadHTTP ψ μ => [(Text, Text)] -> Request -> EitherT Text μ Request Source #

Sets a x-www-form-urlencoded form as the request body (also sets the content-type).

performWithFn :: (MonadHTTP ψ μ, MonadCatch μ) => (ConduitM ι ByteString μ () -> μ ρ) -> Request -> EitherT Text μ (Response ρ) Source #

Performs the request, using a given function to read the body. This is what all other performWith functions are based on.

performWithVoid :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> EitherT Text μ (Response ()) Source #

Performs the request, ignoring the body.

performWithBytes :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> EitherT Text μ (Response LByteString) Source #

Performs the request, reading the body into a lazy ByteString.

Orphan instances