Skip to content

Commit

Permalink
Clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswk committed Jan 15, 2024
1 parent c731115 commit 7fefc52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion server/src/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn filter_features(
}

pub fn filter_features_for_token(features: &ClientFeatures, token: &EdgeToken) -> ClientFeatures {
let f = FeatureFilterSet::from(project_filter(&token));
let f = FeatureFilterSet::from(project_filter(token));
let filtered = features
.features
.iter()
Expand Down
37 changes: 17 additions & 20 deletions server/src/middleware/etag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,25 @@ where
}
_ => body.boxed(),
});
match payload {
Some(bytes) => {
let response_hash = xxh3_128(&bytes);
let base64 = base64::prelude::BASE64_URL_SAFE
.encode(response_hash.to_le_bytes());
let mut buff = Buffer::new();
let _ = write!(buff, "{:x}-{}", bytes.len(), base64);
let tag = EntityTag::new_weak(buff.to_string());
if let Some(request_etag_header) = request_etag_header {
if request_etag_header == IfNoneMatch::Any
|| request_etag_header.to_string() == tag.to_string()
{
modified = false
}
if let Some(bytes) = payload {
let response_hash = xxh3_128(&bytes);
let base64 = base64::prelude::BASE64_URL_SAFE
.encode(response_hash.to_le_bytes());
let mut buff = Buffer::new();
let _ = write!(buff, "{:x}-{}", bytes.len(), base64);
let tag = EntityTag::new_weak(buff.to_string());
if let Some(request_etag_header) = request_etag_header {
if request_etag_header == IfNoneMatch::Any
|| request_etag_header.to_string() == tag.to_string()
{
modified = false
}
if modified {
if let Ok((name, value)) = ETag(tag.clone()).try_into_pair() {
res.headers_mut().insert(name, value);
}
}
if modified {
if let Ok((name, value)) = ETag(tag.clone()).try_into_pair() {
res.headers_mut().insert(name, value);
}
}
None => {}
}

Ok(match modified {
Expand All @@ -140,7 +137,7 @@ where
fn header_to_edgetoken(header: Option<&HeaderValue>) -> Option<EdgeToken> {
header
.map(|h| h.to_str().unwrap())
.map_or(None, |header_str| EdgeToken::from_str(header_str).ok())
.and_then(|header_str| EdgeToken::from_str(header_str).ok())
}

fn we_know_this_etag_from_upstream(
Expand Down

0 comments on commit 7fefc52

Please sign in to comment.