Module erqwest

Data Types

cert_der()

cert_der() = binary()

client()

abstract datatype: client()

client_opts()

client_opts() = #{identity => {pkcs12_der(), password()}, follow_redirects => boolean() | non_neg_integer(), additional_root_certs => [cert_der()], use_built_in_root_certs => boolean()}

default true

err()

err() = #{code := atom(), reason := binary()}

header()

header() = {binary(), binary()}

method()

method() = options | get | post | put | delete | head | trace | connect | patch

password()

password() = binary()

pkcs12_der()

pkcs12_der() = binary()

req()

req() = #{url := url(), method := method(), headers => [header()], body => binary(), timeout => non_neg_integer()}

milliseconds

req_opts()

req_opts() = #{headers => [header()], body => binary(), timeout => non_neg_integer()}

milliseconds

resp()

resp() = #{status := 100..599, body := binary(), headers := [header()]}

url()

url() = binary()

Function Index

close_client/1Close a client and idle connections in its pool.
get/2Convenience wrapper for req/2.
get/3Convenience wrapper for req/2.
make_client/0
make_client/1
post/3Convenience wrapper for req/2.
req/2Make a synchronous request.
req_async/4Make an asynchronous request.
start_client/1Equivalent to start_client(Name, #{}).
start_client/2Start a client registered under Name.
stop_client/1Unregisters and calls close_client/1 on a named client.

Function Details

close_client/1

close_client(Client::client()) -> ok

Close a client and idle connections in its pool. Returns immediately, but the connection pool will not be cleaned up until all in-flight requests for this client have returned.

You do not have to call this function, since the client will automatically be cleaned up when it is garbage collected by the VM.

Fails with reason badarg if the client has already been closed.

get/2

get(Client::client() | atom(), Url::url()) -> {ok, resp()} | {error, err()}

Convenience wrapper for req/2.

get/3

get(Client::client() | atom(), Url::url(), Opts::req_opts()) -> {ok, resp()} | {error, err()}

Convenience wrapper for req/2.

make_client/0

make_client() -> client()

make_client/1

make_client(Opts::client_opts()) -> client()

post/3

post(Client::client() | atom(), Url::url(), Opts::req_opts()) -> {ok, resp()} | {error, err()}

Convenience wrapper for req/2.

req/2

req(Client::client() | atom(), Req::req()) -> {ok, resp()} | {error, err()}

Make a synchronous request.

Fails with reason badarg if any argument is invalid or if the client has already been closed.

req_async/4

req_async(NamedClient::client() | atom(), Pid::pid(), Ref::any(), Req::req()) -> ok

Make an asynchronous request.

Sends {erqwest_response, Ref, {ok, resp()} | {error, err()}} to Pid.

Fails with reason badarg if any argument is invalid or if the client has already been closed.

start_client/1

start_client(Name::atom()) -> ok

Equivalent to start_client(Name, #{}).

start_client/2

start_client(Name::atom(), Opts::client_opts()) -> ok

Start a client registered under Name. The implemenation uses persistent_term and is not intended for clients that will be frequently started and stopped. For such uses see make_client/1.

stop_client/1

stop_client(Name::atom()) -> ok

Unregisters and calls close_client/1 on a named client. This is potentially expensive and should not be called frequently, see start_client/2 for more details.


Generated by EDoc