Slapdash API call demo
I can hit the endpoint and retrieve data. Excellent.
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -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
|
||||
|
||||
20
Cargo.toml
Normal file
20
Cargo.toml
Normal 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
26
src/main.rs
Normal 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(())
|
||||
}
|
||||
Reference in New Issue
Block a user