use crate::rest_api::builder::RestApiBuilder;
use chrono::{DateTime, Utc};
impl<'a> RestApiBuilder<'a> {
pub fn if_match_header(&mut self, etag: &[&str]) -> &Self {
let value = etag
.iter()
.map(|e| {
if e.starts_with('"') && e.ends_with('"') {
e.to_string()
} else {
format!("\"{}\"", e)
}
})
.collect::<Vec<_>>()
.join(", ");
self.header("If-Match", &value)
}
pub fn if_none_match_header(&mut self, etag: &[&str]) -> &Self {
let value = etag
.iter()
.map(|e| {
if e.starts_with('"') && e.ends_with('"') {
e.to_string()
} else {
format!("\"{}\"", e)
}
})
.collect::<Vec<_>>()
.join(", ");
self.header("If-None-Match", &value)
}
pub fn if_modified_since_header(&mut self, time: &DateTime<Utc>) -> &mut Self {
let since = time.format("%a, %d %b %Y %H:%M:%S %:z").to_string();
self.header("If-Modified-Since", &since);
self
}
pub fn if_unmodified_since_header(&mut self, since: &str) -> &mut Self {
self.header("If-Unmodified-Since", since);
self
}
}