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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)