Module serenity::http[][src]

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.

Re-exports

pub use self::client::*;
pub use self::error::Error as HttpError;
pub use self::typing::*;

Modules

Routes are used for ratelimiting. These are to differentiate between the different types of routes - such as getting the current user’s channels - for the most part, with the exception being major parameters.

Structs

An HTTP status code (status-code in RFC 7230 et al.).

Enums

Enum that allows a user to pass a Path or a File type to send_files

Representation of the method of a query to send for the get_guilds function.

An method used for ratelimiting special routes.

Traits

This trait will be required by functions that need Http and can optionally use a Cache to potentially avoid REST-requests.