Concoction v0.1.0 Concoction.HTTP View Source

Utilities for handling commmunication with the Discord API.

This will handle ratelimits, authorization & user agent headers.

Link to this section Summary

Types

The HTTP method used to make the request.

Functions

Initialize the tables required in ETS for the HTTP client. This storage handles information on ratelimit buckets.

Make a request to the Discord API.

Link to this section Types

Specs

method() :: :get | :post | :put | :patch | :delete

The HTTP method used to make the request.

Link to this section Functions

Specs

init() :: :ok

Initialize the tables required in ETS for the HTTP client. This storage handles information on ratelimit buckets.

Link to this function

ratelimit_remaining(url, params)

View Source

Specs

ratelimit_remaining(binary(), [any()]) :: integer()
Link to this function

request(method, path, data \\ %{}, params \\ [])

View Source

Make a request to the Discord API.

When a method is GET, the data parameter is passed as query-string data.

For other requests it is passed as the post body.

If a ratelimit is hit this function will block until the ratelimit is over.

Returns the status code and JSON body or nil for requests with no response.