Function fastly::geo::geo_lookup[][src]

pub fn geo_lookup(ip: IpAddr) -> Option<Geo>

Look up the geographic data associated with a particular IP address.

Returns None if no geographic data is available, such as when the IP address is reserved for private use.

Examples

To get geographic information for the downstream client:

let client_ip = fastly::Request::from_client().get_client_ip_addr().unwrap();
let geo = fastly::geo::geo_lookup(client_ip).unwrap();
if let fastly::geo::ConnType::Satellite = geo.conn_type() {
    println!("receiving a request from outer space 🛸");
}