From 22da3abc0d8055da019b0b0185a09a3387a96e7f Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Thu, 17 Oct 2019 16:56:31 -0700 Subject: [PATCH] use api key from file (todo? envvar fallback) --- .gitignore | 3 ++- src/lib.rs | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 9bdfb5b..d5fedaa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /target **/*.rs.bk -Cargo.lock /doc +Cargo.lock +apikey.txt diff --git a/src/lib.rs b/src/lib.rs index 0e807eb..19c7bc9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,12 +14,14 @@ mod tests { use tokio::runtime::Runtime; use super::*; - const API_KEY: &'static str = "RGAPI-nothinghereowo"; - #[test] fn it_works() { + let api_key_raw = std::fs::read_to_string("apikey.txt").unwrap(); // TODO don't use unwrap. + let api_key = api_key_raw.trim(); + + let rt = Runtime::new().unwrap(); - let riot_api = RiotApi::with_key(API_KEY); + let riot_api = RiotApi::with_key(api_key); // https://na1.api.riotgames.com/lol/champion-mastery/v4/scores/by-summoner/SBM8Ubipo4ge2yj7bhEzL7yvV0C9Oc1XA2l6v5okGMA_nCw let my_future = riot_api.get::("asdf", consts::Region::NA,