MCPcopy Create free account
hub / github.com/aptabase/aptabase / GetClientLocation

Method GetClientLocation

src/Features/GeoIP/CloudGeoClient.cs:20–31  ·  view source on GitHub ↗
(HttpContext httpContext)

Source from the content-addressed store, hash-verified

18 }
19
20 public override GeoLocation GetClientLocation(HttpContext httpContext)
21 {
22 var countryCode = GetHeader(httpContext, "cdn-requestcountrycode", "CloudFront-Viewer-Country", "CF-IPCountry");
23 var regionCode = GetHeader(httpContext, "cdn-requeststatecode", "Cloudfront-Viewer-Country-Region");
24 var regionName = _regions.TryGetValue($"{countryCode}-{regionCode}", out var name) ? name : "";
25
26 return new GeoLocation
27 {
28 CountryCode = countryCode ?? "",
29 RegionName = regionName ?? ""
30 };
31 }
32
33 private static string GetHeader(HttpContext httpContext, params string[] names)
34 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected