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.
This commit is contained in:
[ ] 2022-12-09 05:13:43 +00:00
parent 74de0d15b3
commit 9064888265
1 changed files with 4 additions and 1 deletions

View File

@ -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(),
}
}