Skip to content

Commit 0835e7b

Browse files
Add Support for Fastly Compute@Edge (WASM)
- update FastlyClient to actually set the headers on the request
1 parent 8427838 commit 0835e7b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/flagsmith/client/fastly_client.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,27 @@ pub struct FastlyClient {
8989
}
9090

9191
impl ClientLike for FastlyClient {
92-
fn new(headers: HeaderMap, timeout: std::time::Duration) -> Self {
92+
fn new(headers: HeaderMap, _timeout: std::time::Duration) -> Self {
9393
Self {
9494
default_headers: headers,
9595
}
9696
}
9797

9898
fn request(&self, method: super::client::Method, url: String) -> impl ClientRequestBuilder {
99+
let mut req = http::Request::new(
100+
<flagsmith::client::client::Method as Into<http::Method>>::into(method),
101+
url,
102+
);
103+
104+
for (name, value) in &self.default_headers {
105+
if let Ok(header_val) = value.to_str() {
106+
req.append_header(name.to_string(), header_val);
107+
}
108+
}
109+
99110
FastlyRequestBuilder {
100111
backend: "flagsmith".to_string(),
101-
request: Ok(http::Request::new(
102-
<flagsmith::client::client::Method as Into<http::Method>>::into(method),
103-
url,
104-
)),
112+
request: Ok(req),
105113
}
106114
}
107115
}

0 commit comments

Comments
 (0)