Skip to content

Instantly share code, notes, and snippets.

@eyberg
Created April 9, 2024 23:01
Show Gist options
  • Save eyberg/b5811f16632d48f6168ac1192ac0f308 to your computer and use it in GitHub Desktop.
Save eyberg/b5811f16632d48f6168ac1192ac0f308 to your computer and use it in GitHub Desktop.
eyberg@venus:~/rr/rtest$ ops run target/debug/rtest
running local instance
booting /home/eyberg/.ops/images/rtest ...
en1: assigned 10.0.2.15
en1: assigned FE80::DCBF:CDFF:FEB4:8BB2
{
"origin": "191.96.255.108",
}
eyberg@venus:~/rr/rtest$ cat src/main.rs
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::get("https://httpbin.org/ip")
.await?
.json::<HashMap<String, String>>()
.await?;
println!("{resp:#?}");
Ok(())
}
eyberg@venus:~/rr/rtest$ cat Cargo.toml
[package]
name = "rtest"
version = "0.1.0"
edition = "2021"
[dependencies]
reqwest = { version = "0.12", features = ["json"] }
tokio = { version = "1", features = ["full"] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment