HTTPipe v0.9.0 HTTPipe.Adapter behaviour

The Adapter behaviour that all adapters must implement

Summary

Types

When an adapter fails, it must respond with a valid exception that can be raised

Signature for a failed response from the adapter

The adapter may take certain options that will be passed as the final parameter as a Keyword list. The adapter documentation should list the possible options and their usage

The adapter must return the status code, the headers, and the body for the response

Signature for a successful response from the adapter

Callbacks

Called by HTTPipe.Conn to execute a request and receive a response

Types

exception :: Exception.t

When an adapter fails, it must respond with a valid exception that can be raised

failure :: {:error, exception}

Signature for a failed response from the adapter

options :: Keyword.t

The adapter may take certain options that will be passed as the final parameter as a Keyword list. The adapter documentation should list the possible options and their usage.

response :: {HTTPipe.Response.status_code, HTTPipe.Response.headers, HTTPipe.Response.body}

The adapter must return the status code, the headers, and the body for the response

success :: {:ok, response}

Signature for a successful response from the adapter

Callbacks

execute_request(arg0, arg1, arg2, arg3, options)

Called by HTTPipe.Conn to execute a request and receive a response

This interface is designed to be as simple as possible, so it only has five components to it. Implementers should take care, however, to read up on the expectations of each parameter, especially the body parameter.

The typespecs for each parameter will describe the expectations of those parameters and ways in which those expectations can be modified.

For example, the body parameter accepts tuples to specify special forms. Normally, HTTPipe will handle these tuples prior to calling the adapter’s execute_request/5 method. However, if there are special considerations or your adapter wants to handle these tuples natively, you can defer the processing of the body parameter and have it passed in its original form by specifying the configuration value defer_body_processing as true. (If you utilize this, you can call HTTPipe’s helper functions that it would normally call for any tuple forms you cannot natively handle.)