tsk-79: Changed return type of function and cleaned up other functions
This commit is contained in:
+11
-11
@@ -9,22 +9,22 @@ 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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!({
|
||||
|
||||
Reference in New Issue
Block a user