Faraday ships with some useful middleware that you can use to customize your request/response lifecycle. Middleware are separated into two macro-categories: Request Middleware and Response Middleware. The former usually deal with the request, encoding the parameters or setting headers. The latter instead activate after the request is completed and a response has been received, like parsing the response body, logging useful info or checking the response status.
Request middleware can modify Request details before the Adapter runs. Most middleware set Header values or transform the request body based on the content type.
Authorizationheader to the
Authorizationheader to the specified token.
Faraday::Request#bodyhash of key/value pairs into a multipart form request.
Faraday::Request#bodyhash of key/value pairs into a url-encoded request body.
Retryautomatically retries requests that fail due to intermittent client or server errors (such as network hiccups).
Instrumentationallows to instrument requests using different tools.
Response middleware receives the response from the adapter and can modify its details before returning it.