use only one reqwest::Client
This commit is contained in:
parent
c02ad41306
commit
77bf30fada
|
@ -1097,7 +1097,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rss-anime-notifier-rs"
|
name = "rss-anime-notifier-rs"
|
||||||
version = "0.1.0"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rss-anime-notifier-rs"
|
name = "rss-anime-notifier-rs"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
authors = ["blank X <theblankx@protonmail.com>"]
|
authors = ["blank X <theblankx@protonmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,8 @@ struct AiringSchedule {
|
||||||
pub episode: isize
|
pub episode: isize
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn give_response(anime_id: usize) -> Result<impl warp::Reply, Infallible> {
|
async fn give_response(anime_id: usize, client: Client) -> Result<impl warp::Reply, Infallible> {
|
||||||
let json = json!({"query": QUERY, "variables": {"id": anime_id}});
|
let json = json!({"query": QUERY, "variables": {"id": anime_id}});
|
||||||
let client = Client::new();
|
|
||||||
let resp = match client.post("https://graphql.anilist.co/")
|
let resp = match client.post("https://graphql.anilist.co/")
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
.header("Accept", "application/json")
|
.header("Accept", "application/json")
|
||||||
|
@ -148,7 +147,10 @@ async fn main() {
|
||||||
Ok(port) => port.parse::<u16>().unwrap(),
|
Ok(port) => port.parse::<u16>().unwrap(),
|
||||||
Err(_) => 8080
|
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);
|
let routes = warp::get().and(bare_path);
|
||||||
eprintln!("INFO: Listening on 127.0.0.1:{}", port);
|
eprintln!("INFO: Listening on 127.0.0.1:{}", port);
|
||||||
|
|
Loading…
Reference in New Issue