Expand description
The HTTP module which provides functions for performing requests to endpoints in Discord’s API.
An important function of the REST API is ratelimiting. Requests to endpoints are ratelimited to prevent spam, and once ratelimited Discord will stop performing requests. The library implements protection to pre-emptively ratelimit, to ensure that no wasted requests are made.
The HTTP module comprises of two types of requests:
- REST API requests, which require an authorization token;
- Other requests, which do not require an authorization token.
The former require a Client
to have logged in, while the latter may be made regardless of
any other usage of the library.
If a request spuriously fails, it will be retried once.
Note that you may want to perform requests through a models’ instance methods where possible, as they each offer different levels of a high-level interface to the HTTP module.
Structs§
- Discord
Json Error - Discord
Json Single Error - Error
Response - Http
- Note: For all member functions that return a
Result
, the Error kind will be eitherError::Http
orError::Json
. - Http
Builder - A builder for the underlying
Http
client that performs requests to Discord’s HTTP API - Multipart
- Holder for multipart body. Contains upload data, multipart fields, and payload_json for creating requests with attachments.
- Ratelimit
- A set of data containing information about the ratelimits for a particular
RatelimitingBucket
, which is stored inHttp
. - Ratelimit
Info - Passed to the
Ratelimiter::set_ratelimit_callback
callback. If using Client, that callback is initialized to call theEventHandler::ratelimit()
method. - Ratelimiter
- Ratelimiter for requests to the Discord API.
- Ratelimiting
Bucket - Used to group requests together for ratelimiting.
- Request
- Status
Code - An HTTP status code (
status-code
in RFC 7230 et al.). - Typing
- A struct to start typing in a
Channel
for an indefinite period of time.
Enums§
- Guild
Pagination - Representation of the method of a query to send for the
Http::get_guilds
function. - Http
Error - Light
Method - An method used for ratelimiting special routes.
- Message
Pagination - Multipart
Upload - Route
- User
Pagination - Representation of the method of a query to send for the
Http::get_scheduled_event_users
andHttp::get_bans
functions.
Traits§
- Cache
Http - This trait will be required by functions that need
Http
and can optionally use aCache
to potentially avoid REST-requests.
Functions§
Type Aliases§
- Request
Builder Deprecated