aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2022-11-20 02:39:54 -0500
committerpg9182 <96569817+pg9182@users.noreply.github.com>2022-11-20 06:12:13 -0500
commitff52bfe36e9c28fdc227bf68192777a9c655be08 (patch)
tree33cf7ce731e11bf4c04526cb4ec3a12e3f53ded6 /pkg
parentf4fefa65ec1932056082d69d1bd827afbcb88174 (diff)
downloadAtlas-ff52bfe36e9c28fdc227bf68192777a9c655be08.tar.gz
Atlas-ff52bfe36e9c28fdc227bf68192777a9c655be08.zip
pkg/api/api0: Add GetRegion field
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/api0/api.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/api/api0/api.go b/pkg/api/api0/api.go
index 6e1077f..3fe1f3c 100644
--- a/pkg/api/api0/api.go
+++ b/pkg/api/api0/api.go
@@ -85,6 +85,17 @@ type Handler struct {
// server regions are disabled.
LookupIP func(netip.Addr, ip2location.Field) (ip2location.Record, error)
+ // GetRegion gets the region name from an IP2Location record. If not
+ // provided, server regions are disabled.
+ //
+ // Errors should only be returned for unexpected situations, and a
+ // best-effort region should still be returned if applicable (it will still
+ // be used on error if non-empty).
+ //
+ // Note that it is valid to return an
+ // empty region and no error if no region is to be assigned.
+ GetRegion func(netip.Addr, ip2location.Record) (string, error)
+
metricsInit sync.Once
metricsObj apiMetrics
}