Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tarkah committed Dec 5, 2020
1 parent 85b2dd6 commit 0dda25b
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,7 @@ async fn main() -> Result<(), anyhow::Error> {
.connect_timeout(Duration::from_secs(CONNECTION_TIMEOUT_SECONDS))
.build()?;

let request = Request::builder()
.method("GET")
.uri(&format!(
"{}?gameId=1&sort={}&pageSize={}",
CURSE_SEARCH_URL,
CurseSort::Popularity as u8,
500
))
.body(())
.unwrap();

let packages: Vec<curse::Package> = client.send_async(request).await?.json()?;
let packages = search_packages(&client, CurseSort::Popularity, 500).await?;

println!("{} packages to audit against", packages.len());

Expand Down Expand Up @@ -117,6 +106,23 @@ async fn main() -> Result<(), anyhow::Error> {
Ok(())
}

async fn search_packages(
client: &HttpClient,
sort_type: CurseSort,
num_results: usize,
) -> Result<Vec<curse::Package>, anyhow::Error> {
let request = Request::builder()
.method("GET")
.uri(&format!(
"{}?gameId=1&sort={}&pageSize={}",
CURSE_SEARCH_URL, sort_type as u8, num_results,
))
.body(())
.unwrap();

Ok(client.send_async(request).await?.json()?)
}

async fn get_fingerprint_respose(
client: &HttpClient,
api_choice: ApiChoice,
Expand Down

0 comments on commit 0dda25b

Please sign in to comment.