HTTPoison v1.6.2 HTTPoison.Base behaviour View Source
Provides a default implementation for HTTPoison functions.
This module is meant to be use
'd in custom modules in order to wrap the
functionalities provided by HTTPoison. For example, this is very useful to
build API clients around HTTPoison:
defmodule GitHub do
use HTTPoison.Base
@endpoint "https://api.github.com"
def process_url(url) do
@endpoint <> url
end
end
The example above shows how the GitHub
module can wrap HTTPoison
functionalities to work with the GitHub API in particular; this way, for
example, all requests done through the GitHub
module will be done to the
GitHub API:
GitHub.get("/users/octocat/orgs")
#=> will issue a GET request at https://api.github.com/users/octocat/orgs
Overriding functions
HTTPoison.Base
defines the following list of functions, all of which can be
overridden (by redefining them). The following list also shows the typespecs
for these functions and a short description.
# Called in order to process the url passed to any request method before
# actually issuing the request.
@spec process_url(binary) :: binary
def process_url(url)
# Called to arbitrarily process the request body before sending it with the
# request.
@spec process_request_body(term) :: binary
def process_request_body(body)
# Called to arbitrarily process the request headers before sending them
# with the request.
@spec process_request_headers(term) :: [{binary, term}]
def process_request_headers(headers)
# Called to arbitrarily process the request options before sending them
# with the request.
@spec process_request_options(keyword) :: keyword
def process_request_options(options)
# Called before returning the response body returned by a request to the
# caller.
@spec process_response_body(binary) :: term
def process_response_body(body)
# Used when an async request is made; it's called on each chunk that gets
# streamed before returning it to the streaming destination.
@spec process_response_chunk(binary) :: term
def process_response_chunk(chunk)
# Called to process the response headers before returning them to the
# caller.
@spec process_headers([{binary, term}]) :: term
def process_headers(headers)
# Used to arbitrarily process the status code of a response before
# returning it to the caller.
@spec process_response_status_code(integer) :: term
def process_response_status_code(status_code)
Link to this section Summary
Link to this section Types
Link to this type
body()
View Source
body()
View Source
body() :: HTTPoison.Request.body()
body() :: HTTPoison.Request.body()
Link to this type
headers()
View Source
headers()
View Source
headers() :: HTTPoison.Request.headers()
headers() :: HTTPoison.Request.headers()
Link to this type
method()
View Source
method()
View Source
method() :: HTTPoison.Request.method()
method() :: HTTPoison.Request.method()
Link to this type
options()
View Source
options()
View Source
options() :: HTTPoison.Request.options()
options() :: HTTPoison.Request.options()
Link to this type
params()
View Source
params()
View Source
params() :: HTTPoison.Request.params()
params() :: HTTPoison.Request.params()
Link to this type
request()
View Source
request()
View Source
request() :: HTTPoison.Request.t()
request() :: HTTPoison.Request.t()
Link to this type
response()
View Source
response()
View Source
response() :: HTTPoison.Response.t()
response() :: HTTPoison.Response.t()
Link to this type
url()
View Source
url()
View Source
url() :: HTTPoison.Request.url()
url() :: HTTPoison.Request.url()
Link to this section Callbacks
Link to this callback
delete(url)
View Source
delete(url)
View Source
delete(url()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
delete(url()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
delete(url, headers)
View Source
delete(url, headers)
View Source
delete(url(), headers()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
delete(url(), headers()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
delete(url, headers, options)
View Source
delete(url, headers, options)
View Source
delete(url(), headers(), options()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
delete(url(), headers(), options()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
delete!(url)
View Source
delete!(url)
View Source
delete!(url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
delete!(url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
delete!(url, headers)
View Source
delete!(url, headers)
View Source
delete!(url(), headers()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
delete!(url(), headers()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
delete!(url, headers, options)
View Source
delete!(url, headers, options)
View Source
delete!(url(), headers(), options()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
delete!(url(), headers(), options()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
get(url)
View Source
get(url)
View Source
get(url()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
get(url()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
get(url, headers)
View Source
get(url, headers)
View Source
get(url(), headers()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
get(url(), headers()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
get(url, headers, options)
View Source
get(url, headers, options)
View Source
get(url(), headers(), options()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
get(url(), headers(), options()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
get!(url)
View Source
get!(url)
View Source
get!(url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
get!(url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
get!(url, headers)
View Source
get!(url, headers)
View Source
get!(url(), headers()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
get!(url(), headers()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
get!(url, headers, options)
View Source
get!(url, headers, options)
View Source
get!(url(), headers(), options()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
get!(url(), headers(), options()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
head(url)
View Source
head(url)
View Source
head(url()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
head(url()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
head(url, headers)
View Source
head(url, headers)
View Source
head(url(), headers()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
head(url(), headers()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
head(url, headers, options)
View Source
head(url, headers, options)
View Source
head(url(), headers(), options()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
head(url(), headers(), options()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
head!(url)
View Source
head!(url)
View Source
head!(url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
head!(url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
head!(url, headers)
View Source
head!(url, headers)
View Source
head!(url(), headers()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
head!(url(), headers()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
head!(url, headers, options)
View Source
head!(url, headers, options)
View Source
head!(url(), headers(), options()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
head!(url(), headers(), options()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
options(url)
View Source
options(url)
View Source
options(url()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
options(url()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
options(url, headers)
View Source
options(url, headers)
View Source
options(url(), headers()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
options(url(), headers()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
options(url, headers, options)
View Source
options(url, headers, options)
View Source
options(url(), headers(), options()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
options(url(), headers(), options()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
options!(url)
View Source
options!(url)
View Source
options!(url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
options!(url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
options!(url, headers)
View Source
options!(url, headers)
View Source
options!(url(), headers()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
options!(url(), headers()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
options!(url, headers, options)
View Source
options!(url, headers, options)
View Source
options!(url(), headers(), options()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
options!(url(), headers(), options()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
patch(url, body)
View Source
patch(url, body)
View Source
patch(url(), body()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
patch(url(), body()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
patch(url, body, headers)
View Source
patch(url, body, headers)
View Source
patch(url(), body(), headers()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
patch(url(), body(), headers()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
patch(url, body, headers, options)
View Source
patch(url, body, headers, options)
View Source
patch(url(), body(), headers(), options()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
patch(url(), body(), headers(), options()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
patch!(url, body)
View Source
patch!(url, body)
View Source
patch!(url(), body()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
patch!(url(), body()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
patch!(url, body, headers)
View Source
patch!(url, body, headers)
View Source
patch!(url(), body(), headers()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
patch!(url(), body(), headers()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
patch!(url, body, headers, options)
View Source
patch!(url, body, headers, options)
View Source
patch!(url(), body(), headers(), options()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
patch!(url(), body(), headers(), options()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
post(url, body)
View Source
post(url, body)
View Source
post(url(), body()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
post(url(), body()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
post(url, body, headers)
View Source
post(url, body, headers)
View Source
post(url(), body(), headers()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
post(url(), body(), headers()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
post(url, body, headers, options)
View Source
post(url, body, headers, options)
View Source
post(url(), body(), headers(), options()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
post(url(), body(), headers(), options()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
post!(url, body)
View Source
post!(url, body)
View Source
post!(url(), body()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
post!(url(), body()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
post!(url, body, headers)
View Source
post!(url, body, headers)
View Source
post!(url(), body(), headers()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
post!(url(), body(), headers()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
post!(url, body, headers, options)
View Source
post!(url, body, headers, options)
View Source
post!(url(), body(), headers(), options()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
post!(url(), body(), headers(), options()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
process_headers(list) View Source
Link to this callback
process_request_body(body) View Source
Link to this callback
process_request_headers(headers) View Source
Link to this callback
process_request_options(options) View Source
Link to this callback
process_request_params(params) View Source
Link to this callback
process_request_url(url) View Source
Link to this callback
process_response(response) View Source
Link to this callback
process_response_body(binary) View Source
Link to this callback
process_response_chunk(binary) View Source
Link to this callback
process_response_headers(list) View Source
Link to this callback
process_response_status_code(integer) View Source
Link to this callback
process_status_code(integer) View Source
Link to this callback
process_url(url) View Source
Link to this callback
put(url)
View Source
put(url)
View Source
put(url()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
put(url()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
put(url, body)
View Source
put(url, body)
View Source
put(url(), body()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
put(url(), body()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
put(url, body, headers)
View Source
put(url, body, headers)
View Source
put(url(), body(), headers()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
put(url(), body(), headers()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
put(url, body, headers, options)
View Source
put(url, body, headers, options)
View Source
put(url(), body(), headers(), options()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
put(url(), body(), headers(), options()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
put!(url)
View Source
put!(url)
View Source
put!(url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
put!(url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
put!(url, body)
View Source
put!(url, body)
View Source
put!(url(), body()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
put!(url(), body()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
put!(url, body, headers)
View Source
put!(url, body, headers)
View Source
put!(url(), body(), headers()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
put!(url(), body(), headers()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
put!(url, body, headers, options)
View Source
put!(url, body, headers, options)
View Source
put!(url(), body(), headers(), options()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
put!(url(), body(), headers(), options()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
request(method, url)
View Source
request(method, url)
View Source
request(method(), url()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
request(method(), url()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
request(method, url, body)
View Source
request(method, url, body)
View Source
request(method(), url(), body()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
request(method(), url(), body()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
request(method, url, body, headers)
View Source
request(method, url, body, headers)
View Source
request(method(), url(), body(), headers()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
request(method(), url(), body(), headers()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
request(method, url, body, headers, options)
View Source
request(method, url, body, headers, options)
View Source
request(method(), url(), body(), headers(), options()) ::
{:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
| {:error, HTTPoison.Error.t()}
request(method(), url(), body(), headers(), options()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Link to this callback
request!(method, url)
View Source
request!(method, url)
View Source
request!(method(), url()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
request!(method(), url()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
request!(method, url, body)
View Source
request!(method, url, body)
View Source
request!(method(), url(), body()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
request!(method(), url(), body()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
request!(method, url, body, headers)
View Source
request!(method, url, body, headers)
View Source
request!(method(), url(), body(), headers()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
request!(method(), url(), body(), headers()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
request!(method, url, body, headers, options)
View Source
request!(method, url, body, headers, options)
View Source
request!(method(), url(), body(), headers(), options()) ::
HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
request!(method(), url(), body(), headers(), options()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Link to this callback
start() View Source
Link to this callback
stream_next(arg1)
View Source
stream_next(arg1)
View Source
stream_next(HTTPoison.AsyncResponse.t()) ::
{:ok, HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
stream_next(HTTPoison.AsyncResponse.t()) :: {:ok, HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}