In this PR, I have moved the URL configuration from the context structure to functions. We have three public functions: get_map , lookup_batch and lookup. They will point to "https://ipinfo.io". I have added three new corresponding functions: get_map_v6 , lookup_batch_v6 and lookup_v6. They point to: "https://v6.ipinfo.io".
root@ipv6-test-server:~/rust# cat examples/lookup_batch.rs
use ipinfo::{BatchReqOpts, IpInfo, IpInfoConfig};
use std::env;
#[tokio::main]
async fn main() {
let token = env::args().nth(1);
let config = IpInfoConfig {
token,
..Default::default()
};
let mut ipinfo = IpInfo::new(config).expect("should construct");
let res2 = ipinfo
.lookup_batch_v6(&["2a00:1838:37:107::e3a6", "2a02:4780:10:5bae::1"], BatchReqOpts::default())
.await;
match res2 {
Ok(r) => {
println!("2a00:1838:37:107::e3a6: {:?}", r["2a00:1838:37:107::e3a6"]);
println!("2a02:4780:10:5bae::1: {:?}", r["2a02:4780:10:5bae::1"]);
}
Err(e) => println!("error occurred: {}", &e.to_string()),
}
}
In this PR, I have moved the URL configuration from the context structure to functions. We have three public functions:
get_map
,lookup_batch
andlookup
. They will point to "https://ipinfo.io". I have added three new corresponding functions:get_map_v6
,lookup_batch_v6
andlookup_v6
. They point to: "https://v6.ipinfo.io".