Added custom user-agent
This commit is contained in:
@@ -2,18 +2,23 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use reqwest::ClientBuilder;
|
use reqwest::ClientBuilder;
|
||||||
|
|
||||||
use crate::dance_info::{CompState, DanceInfo, DanceRank, DanceRole};
|
use crate::{
|
||||||
|
app_signature,
|
||||||
|
dance_info::{CompState, DanceInfo, DanceRank, DanceRole},
|
||||||
|
};
|
||||||
|
|
||||||
// mod caching;
|
// mod caching;
|
||||||
pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
|
pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
|
||||||
let client = ClientBuilder::new()
|
let client = ClientBuilder::new()
|
||||||
|
.user_agent(app_signature())
|
||||||
.build()
|
.build()
|
||||||
.map_err(DanceInfoError::ClientBuild)?;
|
.map_err(DanceInfoError::ClientBuild)?;
|
||||||
|
|
||||||
let mut params = HashMap::new();
|
let mut params = HashMap::new();
|
||||||
|
|
||||||
let url = if cfg!(test) {
|
let url = if cfg!(test) {
|
||||||
"https://o5grQU3Y.free.beeceptor.com/lookup2020/find"
|
// "https://o5grQU3Y.free.beeceptor.com/lookup2020/find"
|
||||||
|
"http://localhost:8000"
|
||||||
} else {
|
} else {
|
||||||
"https://points.worldsdc.com/lookup2020/find"
|
"https://points.worldsdc.com/lookup2020/find"
|
||||||
};
|
};
|
||||||
@@ -34,7 +39,7 @@ pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#![allow(clippy::unwrap_used, reason="Allow unwrap in tests")]
|
#![allow(clippy::unwrap_used, reason = "Allow unwrap in tests")]
|
||||||
use crate::worldsdc::fetch_wsdc_info;
|
use crate::worldsdc::fetch_wsdc_info;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user