diff options
-rw-r--r-- | main.go | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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, |