From 1ae404dc90a4aa922652e3bedcdee9c3b0016593 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Sat, 7 Jan 2023 03:24:56 +0100 Subject: refactor: Store global const in separate file (#131) Moved user agent there for now --- src-tauri/src/constants.rs | 3 +++ src-tauri/src/github/release_notes.rs | 4 ++-- src-tauri/src/lib.rs | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 src-tauri/src/constants.rs (limited to 'src-tauri') 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 { 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; -- cgit v1.2.3