Struct twilight_http::request::Request
source · pub struct Request { /* private fields */ }
Implementations§
source§impl Request
impl Request
sourcepub fn builder(route: &Route<'_>) -> RequestBuilder
pub fn builder(route: &Route<'_>) -> RequestBuilder
Create a new request builder.
Examples
Create a request to create a message with a content of “test” in a channel with an ID of 1:
use twilight_http::{request::Request, routing::Route};
let body = br#"{
"content": "test"
}"#
.to_vec();
let request = Request::builder(&Route::CreateMessage { channel_id: 1 })
.body(body)
.build();
sourcepub fn from_route(route: &Route<'_>) -> Self
pub fn from_route(route: &Route<'_>) -> Self
Create a request from only its route information.
If you need to set additional configurations like the body then use
builder
.
Examples
Create a request to get a message with an ID of 2 in a channel with an ID of 1:
use twilight_http::{request::Request, routing::Route};
let request = Request::from_route(&Route::GetMessage {
channel_id: 1,
message_id: 2,
});
sourcepub const fn headers(&self) -> Option<&HeaderMap<HeaderValue>>
pub const fn headers(&self) -> Option<&HeaderMap<HeaderValue>>
Headers to set in the request, if any.
sourcepub const fn ratelimit_path(&self) -> &Path
pub const fn ratelimit_path(&self) -> &Path
Path used for ratelimiting.
Whether to use the client’s authorization token in the request.