Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mre committed May 3, 2023
1 parent 36297da commit 589fd25
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ chrono = "0.4.24"
kuchiki = "0.8.1"
shuttle-axum = { version = "0.15.0" }
shuttle-runtime = { version = "0.15.0" }
once_cell = "1.17.1"

20 changes: 7 additions & 13 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
use axum::{
extract::TypedHeader,
headers::UserAgent
};
use axum::{extract::TypedHeader, headers::UserAgent};
use once_cell::sync::Lazy;
use reqwest::header::HeaderValue;


const DEFAULT_USER_AGENT: HeaderValue = HeaderValue::from_static(
concat!("Readable/", env!("CARGO_PKG_VERSION"))
);

static DEFAULT_USER_AGENT: Lazy<HeaderValue> =
Lazy::new(|| HeaderValue::from_static(concat!("Readable/", env!("CARGO_PKG_VERSION"))));

pub fn forwarded_agent(ua_header: &Option<TypedHeader<UserAgent>>) -> HeaderValue {
match ua_header {
Some(TypedHeader(ua)) => {
HeaderValue::from_str(ua.as_str()).unwrap_or(DEFAULT_USER_AGENT)
},
None => DEFAULT_USER_AGENT,
HeaderValue::from_str(ua.as_str()).unwrap_or_else(|_| DEFAULT_USER_AGENT.clone())
}
None => DEFAULT_USER_AGENT.clone(),
}
}


/// get current date and time as UTC
/// and format as: 1 December, 2017 12:00:00
pub fn get_time() -> String {
Expand Down

0 comments on commit 589fd25

Please sign in to comment.