tiny_dynamo/
fastly_transport.rs1use crate::{Request, Transport};
2use fastly::{Body, Request as FastlyRequest};
3use std::error::Error;
4
5pub struct Fastly {
8 backend: String,
9}
10
11impl Fastly {
12 pub fn new(backend: impl AsRef<str>) -> Self {
14 Self {
15 backend: backend.as_ref().to_string(),
16 }
17 }
18}
19
20impl Transport for Fastly {
21 fn send(
22 &self,
23 signed: Request,
24 ) -> Result<(u16, String), Box<dyn Error>> {
25 let (parts, body) = signed.into_parts();
26 let fastly_body: Body = body.into();
27 let fr: FastlyRequest = http::Request::from_parts(parts, fastly_body).into();
28 let resp = fr.send(&self.backend)?;
29 Ok((resp.get_status().as_u16(), resp.into_body_str()))
30 }
31}