From 6be5aa08776db256bf19ab143b4341836588741e Mon Sep 17 00:00:00 2001 From: Tim Hoiberg Date: Tue, 4 Jul 2023 23:35:08 +0900 Subject: [PATCH] Return a client instead of the builder --- backend/src/api/satori/request.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/api/satori/request.rs b/backend/src/api/satori/request.rs index 306bf27..5dbbee5 100644 --- a/backend/src/api/satori/request.rs +++ b/backend/src/api/satori/request.rs @@ -1,7 +1,7 @@ use std::env; use axum::Json; -use reqwest::{Client, ClientBuilder, StatusCode}; +use reqwest::{Client, StatusCode}; use crate::api::{internal_error, ErrorResponse}; @@ -17,7 +17,7 @@ pub async fn satori_handler() -> Result, (StatusCode, Json anyhow::Result { - let client = satori_client()?.build()?; + let client = satori_client()?; client .get("https://www.satorireader.com/api/studylist/due/count") @@ -38,7 +38,6 @@ async fn get_new_cards() -> anyhow::Result { let client = satori_client()?; client - .build()? .get("https://www.satorireader.com/api/studylist/pending-auto-importable/count") .send() .await? @@ -53,7 +52,7 @@ fn serialize_new_cards_response(body: &str) -> anyhow::Result anyhow::Result { +fn satori_client() -> anyhow::Result { let satori_cookie = env::var("SATORI_COOKIE")?; let mut headers = reqwest::header::HeaderMap::new(); @@ -61,7 +60,8 @@ fn satori_client() -> anyhow::Result { "Cookie", format!("SessionToken={}", satori_cookie).parse().unwrap(), ); - Ok(Client::builder().default_headers(headers)) + + Ok(Client::builder().default_headers(headers).build()?) } #[cfg(test)]