diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2022-02-15 23:15:15 +0100 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2022-02-15 23:19:55 +0100 |
commit | c195f6b03751bbb4012f48b57b5961a10d4d4113 (patch) | |
tree | c15609258454886203f62a12f38157fd04a05e5b | |
parent | 95dcdc7d883d138d17c2e676c1e4cfae0aa2d395 (diff) |
i really should start asking someone for code reviews, or committing
only after a coffee. this yolo attitude is no good for anyone.
this was a silly typo on db98de9. I guess I write write err != nil too
much...
-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, |