pub struct ClientBuilder { /* private fields */ }
Expand description
A builder for Client
.
Implementations§
source§impl ClientBuilder
impl ClientBuilder
sourcepub fn default_allowed_mentions(self, allowed_mentions: AllowedMentions) -> Self
pub fn default_allowed_mentions(self, allowed_mentions: AllowedMentions) -> Self
Set the default allowed mentions setting to use on all messages sent through the HTTP client.
sourcepub fn proxy(self, proxy_url: String, use_http: bool) -> Self
pub fn proxy(self, proxy_url: String, use_http: bool) -> Self
Set the proxy to use for all HTTP(S) requests.
Note that this isn’t currently a traditional proxy, but is for working with something like twilight’s HTTP proxy server.
§Examples
Set the proxy to twilight_http_proxy.internal
:
use twilight_http::Client;
let client = Client::builder()
.proxy("twilight_http_proxy.internal".to_owned(), true)
.build();
sourcepub fn ratelimiter(self, ratelimiter: Option<Box<dyn Ratelimiter>>) -> Self
pub fn ratelimiter(self, ratelimiter: Option<Box<dyn Ratelimiter>>) -> Self
Set a ratelimiter to use.
If the argument is None
then the client’s ratelimiter will be skipped
before making a request.
If this method is not called at all then a default InMemoryRatelimiter
will be
created by ClientBuilder::build
.
sourcepub const fn timeout(self, duration: Duration) -> Self
pub const fn timeout(self, duration: Duration) -> Self
Set the timeout for HTTP requests.
The default is 10 seconds.
sourcepub fn default_headers(self, headers: HeaderMap) -> Self
pub fn default_headers(self, headers: HeaderMap) -> Self
Set a group headers which are sent in every request.
sourcepub const fn remember_invalid_token(self, remember: bool) -> Self
pub const fn remember_invalid_token(self, remember: bool) -> Self
Whether to remember whether the client has encountered an Unauthorized response status.
If the client remembers encountering an Unauthorized response, then it will not process future requests.
Defaults to true.