tiny_dynamo/
reqwest_transport.rs

1use crate::{Request, Transport};
2use reqwest::blocking::Client;
3use std::error::Error;
4
5pub struct Reqwest {
6    client: Client,
7}
8
9impl Default for Reqwest {
10    fn default() -> Self {
11        Self::new()
12    }
13}
14
15impl Reqwest {
16    pub fn new() -> Self {
17        Reqwest {
18            client: Client::new(),
19        }
20    }
21}
22
23impl Transport for Reqwest {
24    fn send(
25        &self,
26        signed: Request,
27    ) -> Result<(u16, String), Box<dyn Error>> {
28        let resp = self
29            .client
30            .post(signed.uri().to_string())
31            .headers(signed.headers().clone())
32            .body(signed.body().clone())
33            .send()?;
34        Ok((resp.status().as_u16(), resp.text()?))
35    }
36}