summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/main.go b/main.go
index 07a1ba5..5f7a66b 100644
--- a/main.go
+++ b/main.go
@@ -183,11 +183,14 @@ type GeolocationJSON struct {
func (jh *jsonHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ipstr := getRemoteIP(req)
- record, err := jh.geoipdb.getRecordForIP(ipstr)
sortedGateways := []string{""}
- if err != nil {
+
+ record, err := jh.geoipdb.getRecordForIP(ipstr)
+ if err == nil {
sortedGateways = jh.geoipdb.sortGateways(record.Location.Latitude, record.Location.Longitude)
hitsPerCountry.With(prometheus.Labels{"country": record.Country.IsoCode}).Inc()
+ } else {
+ log.Println("error while getting record for", ipstr)
}
data := &GeolocationJSON{
ipstr,