From 15bad3778758b27b37c201f32d087eed547be80a Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 21 Apr 2022 21:24:41 +0200 Subject: [PATCH] set user agent --- src/external.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/external.rs b/src/external.rs index d680a6b..fc11831 100644 --- a/src/external.rs +++ b/src/external.rs @@ -8,7 +8,12 @@ pub async fn post_api, B: AsRef>( endpoint: B, mapjson: HashMap, ) -> Result> { - let client = reqwest::Client::new(); + static APP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),); + + let client = reqwest::Client::builder() + .user_agent(APP_USER_AGENT) + .build()?; + let res = client .post(format!("{}{}", server.as_ref(), endpoint.as_ref())) .json(&mapjson)