diff --git a/Cargo.lock b/Cargo.lock index f47b4e9..030816e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1097,7 +1097,7 @@ dependencies = [ [[package]] name = "rss-anime-notifier-rs" -version = "0.1.0" +version = "0.1.2" dependencies = [ "chrono", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index 4124a1a..b8f7d80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rss-anime-notifier-rs" -version = "0.1.1" +version = "0.1.2" authors = ["blank X "] edition = "2018" diff --git a/src/main.rs b/src/main.rs index 07403d3..cbe30e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,9 +73,8 @@ struct AiringSchedule { pub episode: isize } -async fn give_response(anime_id: usize) -> Result { +async fn give_response(anime_id: usize, client: Client) -> Result { let json = json!({"query": QUERY, "variables": {"id": anime_id}}); - let client = Client::new(); let resp = match client.post("https://graphql.anilist.co/") .header("Content-Type", "application/json") .header("Accept", "application/json") @@ -148,7 +147,10 @@ async fn main() { Ok(port) => port.parse::().unwrap(), Err(_) => 8080 }; - let bare_path = warp::path!(usize).and_then(give_response); + let client = Client::new(); + let client = warp::any().map(move || client.clone()); + let log = warp::log("rss-anime-notifier-rs"); + let bare_path = warp::path!(usize).and(client.clone()).and_then(give_response).with(log); let routes = warp::get().and(bare_path); eprintln!("INFO: Listening on 127.0.0.1:{}", port);