diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2023-01-07 03:24:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-07 03:24:56 +0100 |
commit | 1ae404dc90a4aa922652e3bedcdee9c3b0016593 (patch) | |
tree | fe8e0a7e23a1b781dd7388dc5f7d5417e7b7cd92 /src-tauri/src | |
parent | 226bac84db9f37a7cd9e7247a77b6024108a7d9f (diff) | |
download | FlightCore-1ae404dc90a4aa922652e3bedcdee9c3b0016593.tar.gz FlightCore-1ae404dc90a4aa922652e3bedcdee9c3b0016593.zip |
refactor: Store global const in separate file (#131)
Moved user agent there for now
Diffstat (limited to 'src-tauri/src')
-rw-r--r-- | src-tauri/src/constants.rs | 3 | ||||
-rw-r--r-- | src-tauri/src/github/release_notes.rs | 4 | ||||
-rw-r--r-- | src-tauri/src/lib.rs | 1 |
3 files changed, 6 insertions, 2 deletions
diff --git a/src-tauri/src/constants.rs b/src-tauri/src/constants.rs new file mode 100644 index 00000000..9d7e117c --- /dev/null +++ b/src-tauri/src/constants.rs @@ -0,0 +1,3 @@ +// This file stores various global constants values + +pub const APP_USER_AGENT: &str = "R2NorthstarTools/FlightCore"; diff --git a/src-tauri/src/github/release_notes.rs b/src-tauri/src/github/release_notes.rs index a1d174fa..758f7ace 100644 --- a/src-tauri/src/github/release_notes.rs +++ b/src-tauri/src/github/release_notes.rs @@ -1,3 +1,4 @@ +use crate::constants::APP_USER_AGENT; use serde::{Deserialize, Serialize}; use std::vec::Vec; @@ -18,11 +19,10 @@ pub struct FlightCoreVersion { async fn fetch_github_releases_api(url: &str) -> Result<String, String> { println!("Fetching releases notes from GitHub API"); - let user_agent = "R2NorthstarTools/FlightCore"; let client = reqwest::Client::new(); let res = client .get(url) - .header(reqwest::header::USER_AGENT, user_agent) + .header(reqwest::header::USER_AGENT, APP_USER_AGENT) .send() .await .unwrap() diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index f8ea6aba..f0ffa8de 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -4,6 +4,7 @@ use anyhow::{anyhow, Context, Result}; mod northstar; +pub mod constants; mod platform_specific; #[cfg(target_os = "windows")] use platform_specific::windows; |