Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
- newtype ModHttpClient = ModHttpClient Manager
- newHttpClient :: IO ModHttpClient
- type MonadHTTP ψ μ = (HasHttpManager ψ, MonadReader ψ μ, MonadIO μ, MonadBaseControl IO μ)
- runHTTP :: ExceptT ε μ α -> μ (Either ε α)
- reqU :: MonadHTTP ψ μ => URI -> ExceptT Text μ Request
- reqS :: (MonadHTTP ψ μ, ConvertibleStrings σ String) => σ -> ExceptT Text μ Request
- anyStatus :: MonadHTTP ψ μ => Request -> ExceptT Text μ Request
- postForm :: MonadHTTP ψ μ => [(Text, Text)] -> Request -> ExceptT Text μ Request
- performWithFn :: (MonadHTTP ψ μ, MonadCatch μ) => (ConduitM ι ByteString μ () -> μ ρ) -> Request -> ExceptT Text μ (Response ρ)
- performWithVoid :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> ExceptT Text μ (Response ())
- performWithBytes :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> ExceptT Text μ (Response LByteString)
Documentation
newtype ModHttpClient Source #
type MonadHTTP ψ μ = (HasHttpManager ψ, MonadReader ψ μ, MonadIO μ, MonadBaseControl IO μ) Source #
reqS :: (MonadHTTP ψ μ, ConvertibleStrings σ String) => σ -> ExceptT Text μ Request Source #
Creates a request from a string of any type, parsing it into a URI.
anyStatus :: MonadHTTP ψ μ => Request -> ExceptT Text μ Request Source #
Configures the request to not throw errors on error status codes.
postForm :: MonadHTTP ψ μ => [(Text, Text)] -> Request -> ExceptT 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 -> ExceptT 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 -> ExceptT Text μ (Response ()) Source #
Performs the request, ignoring the body.
performWithBytes :: (MonadHTTP ψ μ, MonadCatch μ) => Request -> ExceptT Text μ (Response LByteString) Source #
Performs the request, reading the body into a lazy ByteString.
Orphan instances
Has ModHttpClient α => HasHttpManager α Source # | |