Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/fastly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ impl Fastly {
&self.static_domain_name,
&format!("fastly-{}", self.static_domain_name),
];
let path = path.trim_start_matches('/');

for domain in domains.iter() {
let url = format!("https://api.fastly.com/purge/{domain}/{path}");
self.purge_url(&url).await?;
for domain in domains {
self.purge(domain, path).await?;
}

Ok(())
}

async fn purge_url(&self, url: &str) -> anyhow::Result<()> {
#[instrument(skip(self))]
pub async fn purge(&self, domain: &str, path: &str) -> anyhow::Result<()> {
let path = path.trim_start_matches('/');
let url = format!("https://api.fastly.com/purge/{domain}/{path}");

trace!(?url);

let api_token = self.api_token.expose_secret();
Expand All @@ -69,7 +71,7 @@ impl Fastly {
debug!("sending invalidation request to Fastly");
let response = self
.client
.post(url)
.post(&url)
.headers(headers)
.send()
.await
Expand Down