Skip to content

Commit

Permalink
swap singleton to regular struct
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteOtter committed Jan 19, 2024
1 parent fca0477 commit a80aa45
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/templates/path.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{}
{}
pub fn {}(query: {}{}) -> Result<reqwest::blocking::Response, reqwest::Error> {{
let binding = THANIX_CLIENT.lock().unwrap();
let state = binding.as_ref().unwrap();
pub fn {}(state: &ThanixClient, query: {}{}) -> Result<reqwest::blocking::Response, reqwest::Error> {{
return state.client.{}(format!("{{}}{}?{{}}", state.base_url, serde_qs::to_string(&query).unwrap())).header("Authorization", format!("Token {{}}", state.authentication_token)).send();
}}
2 changes: 1 addition & 1 deletion src/templates/usings.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
use serde_qs;
use reqwest::Url;
use crate::util::THANIX_CLIENT;
use crate::util::ThanixClient;
3 changes: 0 additions & 3 deletions src/templates/util.rs.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::sync::Mutex;

pub struct ThanixClient {
pub client: reqwest::blocking::Client,
pub base_url: String,
pub authentication_token: String,
}

pub static THANIX_CLIENT: Mutex<Option<ThanixClient>> = Mutex::new(None);

0 comments on commit a80aa45

Please sign in to comment.