e109789b18
* Able to retrieve songs * Updated readme * Removed unused import * Code formatting * Version bump
31 lines
801 B
Rust
31 lines
801 B
Rust
use crate::models;
|
|
|
|
pub fn retrieve_url(api: &models::api::Api, with_id: bool, id: &uuid::Uuid) -> String {
|
|
if with_id {
|
|
retrieve_url_with_id(api, id)
|
|
} else {
|
|
retrieve_url_reg(api)
|
|
}
|
|
}
|
|
|
|
fn retrieve_url_reg(api: &models::api::Api) -> String {
|
|
let url = format!("{}api/{}/{}/", api.url, api.version, api.endpoint);
|
|
|
|
url
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
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)
|
|
}
|