set user agent

This commit is contained in:
Alex 2022-04-21 21:24:41 +02:00
parent 2582a64dff
commit 15bad37787

View file

@ -8,7 +8,12 @@ pub async fn post_api<P: DeserializeOwned, A: AsRef<str>, B: AsRef<str>>(
endpoint: B,
mapjson: HashMap<String, String>,
) -> Result<P, Box<dyn Error>> {
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)