From 90648882653378e9f20757f333b81bcf1cc7b252 Mon Sep 17 00:00:00 2001 From: "[ ]" Date: Fri, 9 Dec 2022 05:13:43 +0000 Subject: [PATCH] Add User-Agent to requests Modrinth strongly encourages (via the following response header) that access to their services be done with a uniquely identifying user-agent string. > "x-user-agent-notice": "!!!!! Hey, you! Yes, **you**! You need to > change your User-Agent ASAP or you may be blocked from using > Modrinth's services! For more information see the documentation: > https://docs.modrinth.com/api-spec/#section/User-Agents !!!!!" The one added here follows the documentation recommendation for the "best" example of a user-agent string. --- src/client.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client.rs b/src/client.rs index a0d9d31..6bba001 100644 --- a/src/client.rs +++ b/src/client.rs @@ -14,7 +14,10 @@ impl HopperClient { pub fn new(config: Config) -> Self { Self { config: config, - client: reqwest::Client::new(), + client: reqwest::ClientBuilder::new() + .user_agent(format!("tebibytemedia/hopper/{} (tebibyte.media)", env!("CARGO_PKG_VERSION"))) + .build() + .unwrap(), } }