1use crate::{HttpRequest, Request};
2
3impl Request {
4 pub fn send(&self) -> Result<crate::response::Response, reqwest::Error> {
6 HttpRequest::from(self).send()
7 }
8
9 pub fn send_with_client(
11 &self,
12 client: &reqwest::blocking::Client,
13 ) -> Result<crate::response::Response, reqwest::Error> {
14 HttpRequest::from(self).send_with_client(client)
15 }
16}
17
18impl HttpRequest {
19 pub fn send(&self) -> Result<crate::response::Response, reqwest::Error> {
21 self.send_with_client(&reqwest::blocking::Client::new())
22 }
23
24 pub fn send_with_client(
26 &self,
27 client: &reqwest::blocking::Client,
28 ) -> Result<crate::response::Response, reqwest::Error> {
29 let mut request = client.post(&self.url);
30 for (k, v) in &self.headers {
31 request = request.header(k, v);
32 }
33 request.form(&self.data).send()?.json()
34 }
35}