Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more fields in JSON output #84

Merged
merged 6 commits into from
May 10, 2020
Merged

Conversation

dshelikhov
Copy link
Contributor

we are migrating from deprecated freegeoip, but echoip is missing information that we used. The change adds more fields to JSON output: zip_code, time_zone, region_name, region_code, metro_code(US only)

echoip output

{
  "ip": "37.193.173.92",
  "ip_decimal": 633449820,
  "country": "Russia",
  "country_eu": false,
  "country_iso": "RU",
  "city": "Novosibirsk",
  "latitude": 55.041,
  "longitude": 82.9428,
  "user_agent": {
    "product": "curl",
    "version": "7.47.0",
    "raw_value": "curl/7.47.0"
  }
}

freegeoip output

{
  "ip": "37.193.173.92",
  "country_code": "RU",
  "country_name": "Russia",
  "region_code": "NVS",
  "region_name": "Novosibirsk Oblast",
  "city": "Novosibirsk",
  "zip_code": "630032",
  "time_zone": "Asia/Novosibirsk",
  "latitude": 55.041,
  "longitude": 82.9428,
  "metro_code": 0
}

…tion that we used. The change adds more fields to JSON output: zip_code, time_zone, region_name, region_code, metro_code(US only)
@dshelikhov
Copy link
Contributor Author

The output with new fields looks as follow:

{
  "ip": "37.193.173.92",
  "ip_decimal": 633449820,
  "region_name": "Novosibirsk Oblast",
  "region_code": "NVS",
  "country": "Russia",
  "country_eu": false,
  "country_iso": "RU",
  "city": "Novosibirsk",
  "latitude": 55.041,
  "longitude": 82.9428,
  "user_agent": {
    "product": "curl",
    "version": "7.64.1",
    "raw_value": "curl/7.64.1"
  },
  "zip_code": "630091",
  "time_zone": "Asia/Novosibirsk"
}

Copy link
Owner

@mpolden mpolden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please expand the TestJSONHandlers test to include a response with all these new fields. You can do this by setting the fields in the structs returned by the testDb functions.

http/http.go Outdated Show resolved Hide resolved
iputil/geo/geo.go Show resolved Hide resolved
@dshelikhov
Copy link
Contributor Author

dshelikhov commented Apr 29, 2020

Please expand the TestJSONHandlers test to include a response with all these new fields.

Tests were added

@mpolden mpolden merged commit 226209d into mpolden:master May 10, 2020
@mpolden
Copy link
Owner

mpolden commented May 10, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants