Skip to content

Instantly share code, notes, and snippets.

@sanxiyn
Created January 30, 2019 14:39
Show Gist options
  • Save sanxiyn/b7687c212284b1086cbfba8ebd9f236e to your computer and use it in GitHub Desktop.
Save sanxiyn/b7687c212284b1086cbfba8ebd9f236e to your computer and use it in GitHub Desktop.
// cargo-deps: reqwest="0.9.9", serde="1.0", serde_derive="1.0"
#[macro_use]
extern crate serde_derive;
#[derive(Deserialize)]
struct Ip {
origin: String
}
fn main() -> Result<(), Box<std::error::Error>> {
let url = "http://httpbin.org/ip";
let mut response = reqwest::get(url)?;
let object: Ip = response.json()?;
println!("{}", object.origin);
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment