aboutsummaryrefslogtreecommitdiff
path: root/src/utils.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-01-13 18:15:02 -0800
committerFuwn <[email protected]>2022-01-13 18:15:02 -0800
commitfd98a4e5bf16d9c640def64148296ff6fcdffe38 (patch)
treeea8cd38a892cdc49b316e139fa287abc27a0db60 /src/utils.rs
parentfix(rust): toolchain file wrong format again again (diff)
downloadapi-fd98a4e5bf16d9c640def64148296ff6fcdffe38.tar.xz
api-fd98a4e5bf16d9c640def64148296ff6fcdffe38.zip
fix(utils): user agent ban?HEADmain
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/utils.rs b/src/utils.rs
index a55ddc6..09c8d49 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::{
- constants::{GITHUB_API_ENDPOINT, GITHUB_USER_CONTENT, USER_AGENT},
+ constants::{GITHUB_API_ENDPOINT, GITHUB_USER_CONTENT},
structures::GitHubAPIResponse,
};
@@ -11,7 +11,13 @@ use crate::{
pub async fn github_api() -> Result<GitHubAPIResponse, Box<dyn std::error::Error>> {
let mut client = actix_web::client::Client::new()
.get(GITHUB_API_ENDPOINT)
- .header("User-Agent", USER_AGENT);
+ .header(
+ "User-Agent",
+ format!(
+ "senpy-api - {}",
+ (0..10).map(|_| rand::random::<char>()).collect::<String>()
+ ),
+ );
if std::env::var("GITHUB_TOKEN").is_ok() {
client = client.header(