tsk-79: Simplifying functions (#92)

* tsk-79: Changed return type of function and cleaned up other functions

* tsk-79: Version bump

* tsk-79: Code formatting
This commit was merged in pull request #92.
This commit is contained in:
KD
2025-10-27 12:42:42 -04:00
committed by GitHub
parent 5c9fcf2ec5
commit abd16eeba2
4 changed files with 15 additions and 19 deletions
Generated
+1 -1
View File
@@ -451,7 +451,7 @@ dependencies = [
[[package]]
name = "icarus-dm"
version = "0.8.9"
version = "0.8.10"
dependencies = [
"futures",
"http",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "icarus-dm"
version = "0.8.9"
version = "0.8.10"
rust-version = "1.90"
edition = "2024"
+7 -11
View File
@@ -9,22 +9,18 @@ pub fn retrieve_url(api: &models::api::Api, with_id: bool, id: &uuid::Uuid) -> S
}
fn retrieve_url_reg(api: &models::api::Api) -> String {
let url = format!("{}api/{}/{}/", api.url, api.version, api.endpoint);
url
format!("{}api/{}/{}/", api.url, api.version, api.endpoint)
}
fn retrieve_url_with_id(api: &models::api::Api, id: &uuid::Uuid) -> String {
let url = format!("{}api/{}/{}/{}", api.url, api.version, api.endpoint, id);
url
format!("{}api/{}/{}/{}", api.url, api.version, api.endpoint, id)
}
pub async fn auth_header(
token: &icarus_models::token::AccessToken,
) -> (http::HeaderName, http::HeaderValue) {
let auth = reqwest::header::AUTHORIZATION;
let auth_value = http::HeaderValue::from_str(&token.bearer_token()).unwrap();
(auth, auth_value)
) -> Result<(http::HeaderName, http::HeaderValue), http::header::InvalidHeaderValue> {
match http::HeaderValue::from_str(&token.bearer_token()) {
Ok(auth_value) => Ok((reqwest::header::AUTHORIZATION, auth_value)),
Err(err) => Err(err),
}
}
+6 -6
View File
@@ -61,7 +61,7 @@ impl Upload {
println!("Url: {url:?}");
let mut headers = reqwest::header::HeaderMap::new();
let (auth, auth_val) = syncers::common::auth_header(token).await;
let (auth, auth_val) = syncers::common::auth_header(token).await.unwrap();
headers.insert(auth, auth_val);
headers.insert("Accept", HeaderValue::from_str("*/*").unwrap());
headers.insert("Connection", HeaderValue::from_str("keep-alive").unwrap());
@@ -99,7 +99,7 @@ impl Upload {
let url = format!("{}/{endpoint}", self.api.url);
let mut headers = reqwest::header::HeaderMap::new();
let (auth, auth_val) = syncers::common::auth_header(token).await;
let (auth, auth_val) = syncers::common::auth_header(token).await.unwrap();
headers.insert(auth, auth_val);
let payload = serde_json::json!({
@@ -132,7 +132,7 @@ impl Upload {
let url = format!("{}/{endpoint}", self.api.url);
let mut headers = reqwest::header::HeaderMap::new();
let (auth, auth_val) = syncers::common::auth_header(token).await;
let (auth, auth_val) = syncers::common::auth_header(token).await.unwrap();
headers.insert(auth, auth_val);
let payload = serde_json::json!({
@@ -200,7 +200,7 @@ impl Upload {
println!("Url: {url:?}");
let mut headers = reqwest::header::HeaderMap::new();
let (auth, auth_val) = syncers::common::auth_header(token).await;
let (auth, auth_val) = syncers::common::auth_header(token).await.unwrap();
headers.insert(auth, auth_val);
headers.insert("Accept", HeaderValue::from_str("*/*").unwrap());
headers.insert("Connection", HeaderValue::from_str("keep-alive").unwrap());
@@ -239,7 +239,7 @@ impl Upload {
let url = format!("{}/{endpoint}", self.api.url);
let mut headers = reqwest::header::HeaderMap::new();
let (auth, auth_val) = syncers::common::auth_header(token).await;
let (auth, auth_val) = syncers::common::auth_header(token).await.unwrap();
headers.insert(auth, auth_val);
let payload = serde_json::json!({
@@ -271,7 +271,7 @@ impl Upload {
let url = format!("{}/{endpoint}", self.api.url);
let mut headers = reqwest::header::HeaderMap::new();
let (auth, auth_val) = syncers::common::auth_header(token).await;
let (auth, auth_val) = syncers::common::auth_header(token).await.unwrap();
headers.insert(auth, auth_val);
let payload = serde_json::json!({