Slapdash API call demo

I can hit the endpoint and retrieve data. Excellent.
This commit is contained in:
2025-05-22 17:45:57 -05:00
parent 3171c89248
commit 45b5049d0e
3 changed files with 51 additions and 0 deletions

5
.gitignore vendored
View File

@@ -20,3 +20,8 @@ Cargo.lock
# and can be added to the global gitignore or merged into this file. For a more nuclear # 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. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
# Added by cargo
/target

20
Cargo.toml Normal file
View File

@@ -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"

26
src/main.rs Normal file
View File

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