Function serenity::http::fire [−][src]
pub fn fire<T: DeserializeOwned>(req: Request) -> Result<T>
Fires off a request, deserializing the response reader via the given type bound.
If you don't need to deserialize the response and want the response instance
itself, use request
.
Examples
Create a new message via the RouteInfo::CreateMessage
endpoint and
deserialize the response into a Message
:
use serenity::{ http::{ self, request::RequestBuilder, routing::RouteInfo, }, model::channel::Message, }; let bytes = vec![ // payload bytes here ]; let channel_id = 381880193700069377; let route_info = RouteInfo::CreateMessage { channel_id }; let mut request = RequestBuilder::new(route_info); request.body(Some(&bytes)); let message = http::fire::<Message>(request.build())?; println!("Message content: {}", message.content);