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:
Generated
+1
-1
@@ -451,7 +451,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus-dm"
|
name = "icarus-dm"
|
||||||
version = "0.8.9"
|
version = "0.8.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"http",
|
"http",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus-dm"
|
name = "icarus-dm"
|
||||||
version = "0.8.9"
|
version = "0.8.10"
|
||||||
rust-version = "1.90"
|
rust-version = "1.90"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
|||||||
+7
-11
@@ -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 {
|
fn retrieve_url_reg(api: &models::api::Api) -> String {
|
||||||
let url = format!("{}api/{}/{}/", api.url, api.version, api.endpoint);
|
format!("{}api/{}/{}/", api.url, api.version, api.endpoint)
|
||||||
|
|
||||||
url
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retrieve_url_with_id(api: &models::api::Api, id: &uuid::Uuid) -> String {
|
fn retrieve_url_with_id(api: &models::api::Api, id: &uuid::Uuid) -> String {
|
||||||
let url = format!("{}api/{}/{}/{}", api.url, api.version, api.endpoint, id);
|
format!("{}api/{}/{}/{}", api.url, api.version, api.endpoint, id)
|
||||||
|
|
||||||
url
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn auth_header(
|
pub async fn auth_header(
|
||||||
token: &icarus_models::token::AccessToken,
|
token: &icarus_models::token::AccessToken,
|
||||||
) -> (http::HeaderName, http::HeaderValue) {
|
) -> Result<(http::HeaderName, http::HeaderValue), http::header::InvalidHeaderValue> {
|
||||||
let auth = reqwest::header::AUTHORIZATION;
|
match http::HeaderValue::from_str(&token.bearer_token()) {
|
||||||
let auth_value = http::HeaderValue::from_str(&token.bearer_token()).unwrap();
|
Ok(auth_value) => Ok((reqwest::header::AUTHORIZATION, auth_value)),
|
||||||
|
Err(err) => Err(err),
|
||||||
(auth, auth_value)
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ impl Upload {
|
|||||||
println!("Url: {url:?}");
|
println!("Url: {url:?}");
|
||||||
|
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
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(auth, auth_val);
|
||||||
headers.insert("Accept", HeaderValue::from_str("*/*").unwrap());
|
headers.insert("Accept", HeaderValue::from_str("*/*").unwrap());
|
||||||
headers.insert("Connection", HeaderValue::from_str("keep-alive").unwrap());
|
headers.insert("Connection", HeaderValue::from_str("keep-alive").unwrap());
|
||||||
@@ -99,7 +99,7 @@ impl Upload {
|
|||||||
let url = format!("{}/{endpoint}", self.api.url);
|
let url = format!("{}/{endpoint}", self.api.url);
|
||||||
|
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
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(auth, auth_val);
|
||||||
|
|
||||||
let payload = serde_json::json!({
|
let payload = serde_json::json!({
|
||||||
@@ -132,7 +132,7 @@ impl Upload {
|
|||||||
let url = format!("{}/{endpoint}", self.api.url);
|
let url = format!("{}/{endpoint}", self.api.url);
|
||||||
|
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
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(auth, auth_val);
|
||||||
|
|
||||||
let payload = serde_json::json!({
|
let payload = serde_json::json!({
|
||||||
@@ -200,7 +200,7 @@ impl Upload {
|
|||||||
println!("Url: {url:?}");
|
println!("Url: {url:?}");
|
||||||
|
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
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(auth, auth_val);
|
||||||
headers.insert("Accept", HeaderValue::from_str("*/*").unwrap());
|
headers.insert("Accept", HeaderValue::from_str("*/*").unwrap());
|
||||||
headers.insert("Connection", HeaderValue::from_str("keep-alive").unwrap());
|
headers.insert("Connection", HeaderValue::from_str("keep-alive").unwrap());
|
||||||
@@ -239,7 +239,7 @@ impl Upload {
|
|||||||
let url = format!("{}/{endpoint}", self.api.url);
|
let url = format!("{}/{endpoint}", self.api.url);
|
||||||
|
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
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(auth, auth_val);
|
||||||
|
|
||||||
let payload = serde_json::json!({
|
let payload = serde_json::json!({
|
||||||
@@ -271,7 +271,7 @@ impl Upload {
|
|||||||
let url = format!("{}/{endpoint}", self.api.url);
|
let url = format!("{}/{endpoint}", self.api.url);
|
||||||
|
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
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(auth, auth_val);
|
||||||
|
|
||||||
let payload = serde_json::json!({
|
let payload = serde_json::json!({
|
||||||
|
|||||||
Reference in New Issue
Block a user