aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
}