From 45b5049d0e6346f602209a14a761d00c057a0da3 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Thu, 22 May 2025 17:45:57 -0500 Subject: [PATCH] Slapdash API call demo I can hit the endpoint and retrieve data. Excellent. --- .gitignore | 5 +++++ Cargo.toml | 20 ++++++++++++++++++++ src/main.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore index ab951f8..620f8f6 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,8 @@ Cargo.lock # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + + +# Added by cargo + +/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..41320d2 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "gt-tools" +version = "0.1.0" +edition = "2024" + +[dependencies] +clap = "4.0.32" +reqwest = { version = "0.11.13", features = ["json"] } +serde = "1.0.152" +tokio = { version = "1.24.2", features = ["macros", "rt-multi-thread"] } + +# Packages available in Debian (Sid) +# clap = "4.5.23" +# reqwest = "0.12.15" +# tokio = "1.43.1" + +# Debian (Bookworm) +# clap = "4.0.32" +# reqwest = "0.11.13" +# tokio = "1.24.2" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..346e55e --- /dev/null +++ b/src/main.rs @@ -0,0 +1,26 @@ + +use reqwest::Error; +use reqwest::header::{ + USER_AGENT, + ACCEPT +}; + +#[tokio::main] +async fn main() -> Result<(), Error> { + let request_url = format!( + "http:/localhost:3000/api/v1/repos/{owner}/{repo}/releases", + owner = "robert", + repo = "rcalc", + ); + let client = reqwest::Client::new(); + let response = client + .get(request_url) + .header(USER_AGENT, "gt-tools-test-agent") + .header(ACCEPT, "application/json") + .send() + .await?; + let body_text: String = response.text().await?; + + println!("{:?}", body_text); + Ok(()) +}