Created
January 30, 2019 14:39
-
-
Save sanxiyn/b7687c212284b1086cbfba8ebd9f236e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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