Fastly Compute C++ SDK
Loading...
Searching...
No Matches
fastly::geo Namespace Reference

Classes

class  Geo
 The geographic data associated with a particular IP address. More...
class  UtcOffset

Functions

fastly::expected< std::optional< Geo > > geo_lookup (std::string_view ip)

Function Documentation

◆ geo_lookup()

fastly::expected< std::optional< Geo > > fastly::geo::geo_lookup ( std::string_view ip)

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

Returns std::nullopt 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:

auto geo{fastly::geo::geo_lookup(client_ip).value()};
if (geo.conn_type() == fastly::geo::ConnType::Satellite) {
std::cout << "receiving a request from outer space 🛸";
}
static Request from_client()
std::optional< std::string > get_client_ip_addr()
Definition geo.h:10
fastly::expected< std::optional< Geo > > geo_lookup(std::string_view ip)