req is:module

The documentation below is structured in such a way that the most important information is presented first: you learn how to do HTTP requests, how to embed them in the monad you have, and then it gives you details about less-common things you may want to know about. The documentation is written with sufficient coverage of details and examples, and it's designed to be a complete tutorial on its own.

About the library

Req is an HTTP client library that attempts to be easy-to-use, type-safe, and expandable. “Easy-to-use” means that the library is designed to be beginner-friendly so it's simple to add to your monad stack, intuitive to work with, well-documented, and does not get in your way. Doing HTTP requests is a common task and a Haskell library for this should be approachable and clear to beginners, thus certain compromises were made. For example, one cannot currently modify ManagerSettings of the default manager because the library always uses the same implicit global manager for simplicity and maximal connection sharing. There is a way to use your own manager with different settings, but it requires more typing. “Type-safe” means that the library tries to eliminate certain classes of errors. For example, we have correct-by-construction URLs; it is guaranteed that the user does not send the request body when using methods like GET or OPTIONS, and the amount of implicit assumptions is minimized by making the user specify their intentions in an explicit form. For example, it's not possible to avoid specifying the body or the method of a request. Authentication methods that assume HTTPS force the user to use HTTPS at the type level. “Expandable” refers to the ability to create new components without having to resort to hacking. For example, it's possible to define your own HTTP methods, create new ways to construct the body of a request, create new authorization options, perform a request in a different way, and create your own methods to parse a response.

Using with other libraries

  • You won't need the low-level interface of http-client most of the time, but when you do, it's better to do a qualified import, because http-client has naming conflicts with req.
  • For streaming of large request bodies see the companion package req-conduit: https://hackage.haskell.org/package/req-conduit.

Lightweight, no risk solution

The library uses the following mature packages under the hood to guarantee you the best experience: It's important to note that since we leverage well-known libraries that the whole Haskell ecosystem uses, there is no risk in using req. The machinery for performing requests is the same as with http-conduit and wreq. The only difference is the API.
The functions in this module allow you to limit the total size of incoming request bodies. Limiting incoming request body size helps protect your server against denial-of-service (DOS) attacks, in which an attacker sends huge bodies to your server.
Some helpers for interrogating a WAI Request.
An interface to PKCS#10 certificate request.
Represents a request of a screen object in a given orientation. These are primarily used in container implementations when allocating a natural size for children calling. See [funcdistributeNaturalAllocation].
A GtkRequisition represents the desired size of a widget. See GtkWidget’s geometry management section for more information.
This module provides data types and helper methods, which makes possible to build alternative API request intepreters in addition to provided IO functions. Simple example using operational package. See samples/Operational/Operational.hs
type GithubMonad a = Program (GH.Request 'False) a

-- | Intepret GithubMonad value into IO
runMonad :: Manager -> GH.Auth -> GithubMonad a -> ExceptT GH.Error IO a
runMonad mgr auth m = case view m of
Return a   -> return a
req :>>= k -> do
b <- ExceptT $ GH.executeRequestWithMgr mgr auth req
runMonad mgr auth (k b)

-- | Lift request into Monad
githubRequest :: GH.Request 'False a -> GithubMonad a
githubRequest = singleton
Represents a request of a screen object in a given orientation. These are primarily used in container implementations when allocating a natural size for children. See [funcdistributeNaturalAllocation].
Represents the desired size of a widget. See GtkWidget’s geometry management section for more information.
Requests processed by handlers.
Request to be run against Elasticsearch servers..
Possible causes of failure of request.